svn commit: r230964 - /jakarta/bcel/trunk/src/java/org/apache/bcel/util/ClassPath.java

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
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();
+	}
   }
 
   /**
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.