Should I close InputStream from org.apache.commons.io.IOUtils

I use the answer to How to convert InputStream to a virtual file that uses a org.apache.commons.io.IOUtilscopy of this InputStreamto FileOutputStreamin order to create File.

Should I close InputStream?

+4
source share
2 answers

It is best to close the InputStream. See question .

org.apache.commons.io.IOUtils.copydo not close streams. Therefore you need to close.

See Javadoc

. , . , .

+6

. , , -, InputStream , OutputStream. InputStream (. @Adi). OutputStream try-with-resources, , .

, , Java 7 try-with-resources, , .

try-with-resources - try, . - , . try-with-resources , .

, OutputStream, , OutputStream , try-with-resource.

InputStream .

+1

All Articles