jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject svn commit: r230964 - /jakarta/bcel/trunk/src/java/org/apache/bcel/util/ClassPath.java
Date Tue, 09 Aug 2005 03:50:50 GMT
Author: dbrosius
Date: Mon Aug  8 20:50:43 2005
New Revision: 230964

URL: http://svn.apache.org/viewcvs?rev=230964&view=rev
Log:
make sure streams are closed, even on exception

Modified:
    jakarta/bcel/trunk/src/java/org/apache/bcel/util/ClassPath.java

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/util/ClassPath.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/util/ClassPath.java?rev=230964&r1=230963&r2=230964&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/util/ClassPath.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/util/ClassPath.java Mon Aug  8 20:50:43 2005
@@ -220,17 +220,22 @@
    * @return byte array for file on class path
    */
   public byte[] getBytes(String name, String suffix) throws IOException {
-    InputStream is = getInputStream(name, suffix);
+	DataInputStream dis = null;
+	try {
+      InputStream is = getInputStream(name, suffix);
     
-    if(is == null)
-      throw new IOException("Couldn't find: " + name + suffix);
+      if(is == null)
+        throw new IOException("Couldn't find: " + name + suffix);
 
-    DataInputStream dis   = new DataInputStream(is);
-    byte[]          bytes = new byte[is.available()];
-    dis.readFully(bytes);
-    dis.close(); is.close();
+      dis   = new DataInputStream(is);
+      byte[]          bytes = new byte[is.available()];
+      dis.readFully(bytes);
 
-    return bytes;
+      return bytes;
+	} finally {
+      if (dis != null)
+		dis.close();
+	}
   }
 
   /**



---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org


Mime
View raw message