This version should be more efficient and cleaner too. Will do the old code with comments too. Bojan
--- /home/groups/devel/jakarta/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java Mon Sep 17 11:51:16 2001 +++ +jakarta-tomcat-changed/src/share/org/apache/tomcat/util/depend/DependClassLoader.java + Wed Sep 19 10:10:21 2001 @@ -263,32 +263,19 @@ return parent; } - private byte[] readFully( InputStream is ) - throws IOException + private byte[] readFully(InputStream is) + throws IOException { - byte b[]=new byte[1024]; - int count=0; + int length; + byte[] store=new byte[1024]; + ByteArrayOutputStream buf=new ByteArrayOutputStream(); - int available=1024; - - while (true) { - int nRead = is.read(b,count,available); - if( nRead== -1 ) { - // we're done reading - byte result[]=new byte[count]; - System.arraycopy( b, 0, result, 0, count ); - return result; - } - // got a chunk - count += nRead; - available -= nRead; - if( available == 0 ) { - // buffer full - byte b1[]=new byte[ b.length * 2 ]; - available=b.length; - System.arraycopy( b, 0, b1, 0, b.length ); - b=b1; - } - } + while((length=is.read(store))!=-1) buf.write(store,0,length); + + buf.flush(); + store=buf.toByteArray(); + buf.close(); + + return store; } }