Close stream - File Downloader

Hello all,

I have a question regarding downloading a file and closing the stream.

In the example a new ByteArrayOutputStream and InputStream is created, but never closed.

Is this correct? Who is closing the streams?

Best Regards,

It is not mandatory. The close operation of those is NOP. See also here.

Perfect. Thanks fot the answer!

Maybe this will enligthen you : )

					//test if it's an image
					if(getFileExtension(aUploadedFile)) {

						OneFiletoUpload oftu = new OneFiletoUpload();

						FileOutputStream fos = new FileOutputStream(aUploadedFile);

						int read = 0;
						byte[] bytes = new byte[1024]


						while ((read = != -1) {
							fos.write(bytes, 0, read);