I wrote a method to read information from S3 object. There are multiple records in S3Object, what's the best way to read all the lines. Does it only read the first line of the object? How to make sure all the lines are read? Anyone can provide some suggestion?
while ((line = reader.readLine()) != null) {
map = objectMapper.readValue(line, new TypeReference<Map<String, Object>>() {});
public Map<String, Object> readS3ObjectData(@NonNull S3Object s3Object) throws IOException {
S3ObjectInputStream s3InputStream = s3Object.getObjectContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(s3InputStream, StandardCharsets.UTF_8));
String line = "";
Map<String, Object> map = new HashMap<>();
while ((line = reader.readLine()) != null) {
map = objectMapper.readValue(line, new TypeReference<Map<String, Object>>() {});
LOGGER.info("Create Object mapper successfully");
}
reader.close();
s3InputStream.close();
return map;
}