From: Niki Roo Date: Sat, 27 Apr 2019 15:08:12 +0000 (+0200) Subject: fix BufferedInputStream offset + jdoc X-Git-Tag: fanfix-swing-0.0.1~21^2~116 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=eeb2cc17c4dbbbf9eb7f4c6ef695226a66fbf106;p=fanfix-swing.git fix BufferedInputStream offset + jdoc --- diff --git a/src/be/nikiroo/utils/BufferedInputStream.java b/src/be/nikiroo/utils/BufferedInputStream.java index b236f8da..9db12f19 100644 --- a/src/be/nikiroo/utils/BufferedInputStream.java +++ b/src/be/nikiroo/utils/BufferedInputStream.java @@ -201,9 +201,6 @@ public class BufferedInputStream extends InputStream { /** * Check if this stream is totally spent (no more data to read or to * process). - *

- * 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; } diff --git a/src/be/nikiroo/utils/NextableInputStream.java b/src/be/nikiroo/utils/NextableInputStream.java index 37322c9e..7e2766ad 100644 --- a/src/be/nikiroo/utils/NextableInputStream.java +++ b/src/be/nikiroo/utils/NextableInputStream.java @@ -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). + *

+ * 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. *