I have Uploaded a Large Excel file in to S3 bucket Using Java
My requirement is to read the Excel file stored in S3 bucket Using Java
and pass it to Ui in form of string or Json.
I have used apache poi XSSFWORKBOOK but it gives out of memory
and upstream error
Tried to convert the inputstream data to string but while printing the content
in string form its in an unreadable some kind of xml form.
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, filePath);
int customBufferSize = 8192;
S3Object s3Object = s3Client.getObject(getObjectRequest);
String csv = new BufferedReader(new InputStreamReader(s3Object.getObjectContent(), StandardCharsets.UTF_8), customBufferSize)
.lines().collect(Collectors.joining("n"));
String json = CDL.toJSONArray(csv).toString(2);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity<>(json, headers, HttpStatus.OK);
Gives Memory Out Of Error For this Piece of Code
and While converting to String it shows character in an binary or xml which is not understandable
Arun Menon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.