以下是我收到的警告信息:
S3AbortableInputStream:未能从S3ObjectInputStream读取所有字节,中止HTTP连接。这可能是一个错误,并可能导致次优行为。通过分段GET请求仅请求您需要的字节或在使用后排除输入流,可以避免这种情况。
我尝试使用try-with-resources,但似乎无法通过此方法关闭S3ObjectInputStream。
try (S3Object s3object = s3Client.getObject(new GetObjectRequest(bucket, key));
S3ObjectInputStream s3ObjectInputStream = s3object.getObjectContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectInputStream, StandardCharsets.UTF_8));
){
//some code here blah blah blah
}
我还尝试了下面的代码并明确关闭,但也没有用:
S3Object s3object = s3Client.getObject(new GetObjectRequest(bucket, key));
S3ObjectInputStream s3ObjectInputStream = s3object.getObjectContent();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectInputStream, StandardCharsets.UTF_8));
){
//some code here blah blah
s3ObjectInputStream.close();
s3object.close();
}
任何帮助都将不胜感激。
附:我只从S3读取文件的两行数据,而该文件还有更多数据。