FileOutputStream is never closed

The output file stream is not closed, so it is still in use by the Java process after the code runs. I noticed this when trying to delete the output files right afterwards.
This commit is contained in:
Holger Ludvigsen 2018-11-05 15:39:11 +01:00 committed by GitHub
parent d83eb69567
commit 770b28f241
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -45,6 +45,7 @@ public class FileDownload {
FileOutputStream fileOutputStream = new FileOutputStream(localFilename); FileChannel fileChannel = fileOutputStream.getChannel()) {
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
fileOutputStream.close();
}
}