Author: nextgens
Date: 2007-04-14 20:41:36 +0000 (Sat, 14 Apr 2007)
New Revision: 12723

Modified:
   trunk/freenet/src/freenet/crypt/SHA256.java
Log:
SHA256: don't use InputStream.available()

Modified: trunk/freenet/src/freenet/crypt/SHA256.java
===================================================================
--- trunk/freenet/src/freenet/crypt/SHA256.java 2007-04-14 20:33:03 UTC (rev 
12722)
+++ trunk/freenet/src/freenet/crypt/SHA256.java 2007-04-14 20:41:36 UTC (rev 
12723)
@@ -309,16 +309,11 @@
      */
        public static void hash(InputStream is, MessageDigest md) throws 
IOException {
                try {
-                       long length = is.available();
-                       long bytesRead = 0;
                        byte[] buf = new byte[4096];
-                       while(length > -1) {
-                               int readBytes = is.read(buf);
-                               if(readBytes < 0) break;
-                               bytesRead += readBytes;
-                               if(readBytes > 0)
+                       int readBytes = is.read(buf);
+                       while(readBytes > -1) {
                                        md.update(buf, 0, readBytes);
-                               length = is.available();
+                                       readBytes = is.read(buf);
                        }
                } finally {
                        if(is != null) is.close();


Reply via email to