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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to