Browse Source

Use FileUtils.close()

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278256 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
30c0d31cc4
2 changed files with 9 additions and 49 deletions
  1. +5
    -28
      src/main/org/apache/tools/ant/taskdefs/BUnzip2.java
  2. +4
    -21
      src/main/org/apache/tools/ant/taskdefs/GUnzip.java

+ 5
- 28
src/main/org/apache/tools/ant/taskdefs/BUnzip2.java View File

@@ -23,6 +23,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.bzip2.CBZip2InputStream; import org.apache.tools.bzip2.CBZip2InputStream;


/** /**
@@ -82,34 +83,10 @@ public class BUnzip2 extends Unpack {
String msg = "Problem expanding bzip2 " + ioe.getMessage(); String msg = "Problem expanding bzip2 " + ioe.getMessage();
throw new BuildException(msg, ioe, getLocation()); throw new BuildException(msg, ioe, getLocation());
} finally { } finally {
if (bis != null) {
try {
bis.close();
} catch (IOException ioex) {
// ignore
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException ioex) {
// ignore
}
}
if (out != null) {
try {
out.close();
} catch (IOException ioex) {
// ignore
}
}
if (zIn != null) {
try {
zIn.close();
} catch (IOException ioex) {
// ignore
}
}
FileUtils.close(bis);
FileUtils.close(fis);
FileUtils.close(out);
FileUtils.close(zIn);
} }
} }
} }


+ 4
- 21
src/main/org/apache/tools/ant/taskdefs/GUnzip.java View File

@@ -22,6 +22,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.FileUtils;


/** /**
* Expands a file that has been compressed with the GZIP * Expands a file that has been compressed with the GZIP
@@ -70,27 +71,9 @@ public class GUnzip extends Unpack {
String msg = "Problem expanding gzip " + ioe.getMessage(); String msg = "Problem expanding gzip " + ioe.getMessage();
throw new BuildException(msg, ioe, getLocation()); throw new BuildException(msg, ioe, getLocation());
} finally { } finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ioex) {
//ignore
}
}
if (out != null) {
try {
out.close();
} catch (IOException ioex) {
//ignore
}
}
if (zIn != null) {
try {
zIn.close();
} catch (IOException ioex) {
//ignore
}
}
FileUtils.close(fis);
FileUtils.close(out);
FileUtils.close(zIn);
} }
} }
} }


Loading…
Cancel
Save