Keep reading in BufferedInputStream.read until in.available() <= 0

This corresponds to the documented behavior of OpenJDK's version.
This commit is contained in:
Joel Dice 2010-09-17 16:08:42 -06:00
parent 20990950bb
commit 7fffba29e6

View File

@ -58,14 +58,19 @@ public class BufferedInputStream extends InputStream {
length -= remaining; length -= remaining;
} }
if (length > 0) { while (length > 0) {
int c = in.read(b, offset, length); int c = in.read(b, offset, length);
if (c == -1) { if (c == -1) {
if (count == 0) { if (count == 0) {
count = -1; count = -1;
} }
break;
} else { } else {
count += c; count += c;
if (in.available() <= 0) {
break;
}
} }
} }