From 30c0d31cc4e6eba6ffc9ead619b6f9f1d5181af3 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 13 May 2005 08:13:50 +0000 Subject: [PATCH] Use FileUtils.close() git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278256 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/BUnzip2.java | 33 +++---------------- .../org/apache/tools/ant/taskdefs/GUnzip.java | 25 +++----------- 2 files changed, 9 insertions(+), 49 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java b/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java index b5669d29b..8833d6144 100644 --- a/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java +++ b/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java @@ -23,6 +23,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.util.FileUtils; import org.apache.tools.bzip2.CBZip2InputStream; /** @@ -82,34 +83,10 @@ public class BUnzip2 extends Unpack { String msg = "Problem expanding bzip2 " + ioe.getMessage(); throw new BuildException(msg, ioe, getLocation()); } 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); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java index 44dbbca98..3cca5ecdd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java +++ b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java @@ -22,6 +22,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.util.FileUtils; /** * 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(); throw new BuildException(msg, ioe, getLocation()); } 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); } } }