fix BufferedInputStream offset + jdoc
authorNiki Roo <niki@nikiroo.be>
Sat, 27 Apr 2019 15:08:12 +0000 (17:08 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 27 Apr 2019 15:08:12 +0000 (17:08 +0200)
src/be/nikiroo/utils/BufferedInputStream.java
src/be/nikiroo/utils/NextableInputStream.java

index b236f8dac290d5406f18c8e758e62804a3f0af1c..9db12f1926cc372544998ae6128a20016370c0e7 100644 (file)
@@ -201,9 +201,6 @@ public class BufferedInputStream extends InputStream {
        /**
         * Check if this stream is totally spent (no more data to read or to
         * process).
-        * <p>
-        * Note: an empty stream that is still not started will return FALSE, as we
-        * don't know yet if it is empty.
         * 
         * @return TRUE if it is
         */
@@ -246,7 +243,7 @@ public class BufferedInputStream extends InputStream {
                        if (hasMoreData()) {
                                int now = Math.min(blen, len) - pos;
                                if (now > 0) {
-                                       System.arraycopy(buffer, pos, b, boff, now);
+                                       System.arraycopy(buffer, pos, b, boff + done, now);
                                        pos += now;
                                        done += now;
                                }
index 37322c9e8e0d7c5f7b651f44a817aecbe6469e5b..7e2766ad950d6f10efa0dbd5c16214ebcb581605 100644 (file)
@@ -111,6 +111,20 @@ public class NextableInputStream extends BufferedInputStream {
                return next(true);
        }
 
+       /**
+        * Check if this stream is totally spent (no more data to read or to
+        * process).
+        * <p>
+        * Note: an empty stream that is still not started will return FALSE, as we
+        * don't know yet if it is empty.
+        * 
+        * @return TRUE if it is
+        */
+       @Override
+       public boolean eof() {
+               return super.eof();
+       }
+       
        /**
         * Check if we still have some data in the buffer and, if not, fetch some.
         *