It will be closed for my intention.
CodePudding user response:
If you didn't close the S3Object
, it would lead to resource leaks.
The S3Object
class should be closed to release the resources it holds, as it implements the Closeable
interface; resources, in this case, would be network connection(s) to Amazon S3.
This is also explained in the AWS Developer Blog:
S3Object
contains anS3ObjectInputStream
that lets you stream down your data over the HTTP connection from Amazon S3. Since the HTTP connection is open and waiting, it’s important to read the stream quickly after callinggetObject
and to remember to close the stream so that the HTTP connection can be released properly.