@@ -44,12 +44,10 @@ protected ZipFileProvider(
4444
4545 public List <String > getTargetList () {
4646 List <String > targetList ;
47- try {
48- ReadableByteChannel readableByteChannel =
49- Channels .newChannel (URL .of (URI .create (sourceUrl ), null ).openStream ());
50- FileOutputStream fileOutputStream = new FileOutputStream (zipFilename );
47+ try (ReadableByteChannel readableByteChannel =
48+ Channels .newChannel (URL .of (URI .create (sourceUrl ), null ).openStream ());
49+ FileOutputStream fileOutputStream = new FileOutputStream (zipFilename )) {
5150 fileOutputStream .getChannel ().transferFrom (readableByteChannel , 0 , Long .MAX_VALUE );
52- fileOutputStream .close ();
5351 } catch (IOException e ) {
5452 LOGGER .error ("Could not download the current {} list with error " , listName , e );
5553 }
@@ -60,13 +58,13 @@ public List<String> getTargetList() {
6058 }
6159 File newFile = new File (outputFile );
6260 // write file content
63- FileOutputStream fos = new FileOutputStream (newFile );
64- int len ;
65- byte [] buffer = new byte [1024 ];
66- while ((len = zis .read (buffer )) > 0 ) {
67- fos .write (buffer , 0 , len );
61+ try (FileOutputStream fos = new FileOutputStream (newFile )) {
62+ int len ;
63+ byte [] buffer = new byte [1024 ];
64+ while ((len = zis .read (buffer )) > 0 ) {
65+ fos .write (buffer , 0 , len );
66+ }
6867 }
69- fos .close ();
7068 } catch (IOException e ) {
7169 LOGGER .error ("Could not unzip the current {} list with error " , listName , e );
7270 }
0 commit comments