From eeb2cc17c4dbbbf9eb7f4c6ef695226a66fbf106 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 27 Apr 2019 17:08:12 +0200 Subject: [PATCH] fix BufferedInputStream offset + jdoc --- src/be/nikiroo/utils/BufferedInputStream.java | 5 +---- src/be/nikiroo/utils/NextableInputStream.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/be/nikiroo/utils/BufferedInputStream.java b/src/be/nikiroo/utils/BufferedInputStream.java index b236f8d..9db12f1 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 37322c9..7e2766a 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. * -- 2.27.0