summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2017-11-18 09:45:25 +1100
committermd_5 <git@md-5.net>2017-11-18 09:45:25 +1100
commitab525c0a154f53750ac057f63bb1724cb2c98fad (patch)
treead79e4c459e0451dde9240a4d7d77abd9f15f42b /src/main/java/org
parent151fa1cb1fca46b076c92cc32ca8f7b6beabaeb3 (diff)
downloadbuildtools-ab525c0a154f53750ac057f63bb1724cb2c98fad.tar
buildtools-ab525c0a154f53750ac057f63bb1724cb2c98fad.tar.gz
buildtools-ab525c0a154f53750ac057f63bb1724cb2c98fad.tar.lz
buildtools-ab525c0a154f53750ac057f63bb1724cb2c98fad.tar.xz
buildtools-ab525c0a154f53750ac057f63bb1724cb2c98fad.zip
BUILDTOOLS-19: Close ZipFile after extraction
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/spigotmc/builder/Builder.java62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java
index 3204307..c11c47a 100644
--- a/src/main/java/org/spigotmc/builder/Builder.java
+++ b/src/main/java/org/spigotmc/builder/Builder.java
@@ -668,42 +668,48 @@ public class Builder
targetFolder.mkdir();
ZipFile zip = new ZipFile( zipFile );
- for ( Enumeration<? extends ZipEntry> entries = zip.entries(); entries.hasMoreElements(); )
+ try
{
- ZipEntry entry = entries.nextElement();
-
- if ( filter != null )
+ for ( Enumeration<? extends ZipEntry> entries = zip.entries(); entries.hasMoreElements(); )
{
- if ( !filter.apply( entry.getName() ) )
+ ZipEntry entry = entries.nextElement();
+
+ if ( filter != null )
{
- continue;
+ if ( !filter.apply( entry.getName() ) )
+ {
+ continue;
+ }
}
- }
- File outFile = new File( targetFolder, entry.getName() );
+ File outFile = new File( targetFolder, entry.getName() );
- if ( entry.isDirectory() )
- {
- outFile.mkdirs();
- continue;
- }
- if ( outFile.getParentFile() != null )
- {
- outFile.getParentFile().mkdirs();
- }
+ if ( entry.isDirectory() )
+ {
+ outFile.mkdirs();
+ continue;
+ }
+ if ( outFile.getParentFile() != null )
+ {
+ outFile.getParentFile().mkdirs();
+ }
- InputStream is = zip.getInputStream( entry );
- OutputStream os = new FileOutputStream( outFile );
- try
- {
- ByteStreams.copy( is, os );
- } finally
- {
- is.close();
- os.close();
- }
+ InputStream is = zip.getInputStream( entry );
+ OutputStream os = new FileOutputStream( outFile );
+ try
+ {
+ ByteStreams.copy( is, os );
+ } finally
+ {
+ is.close();
+ os.close();
+ }
- System.out.println( "Extracted: " + outFile );
+ System.out.println( "Extracted: " + outFile );
+ }
+ } finally
+ {
+ zip.close();
}
}