On 20/12/2020 19:15, Philippe Marschall wrote:
On 20.12.20 18:47, Rob Spoor wrote:
...
That "> 0" is incorrect here; it's allowed to return 0 before EOF
I don't think the method is allowed to return 0 before EOF. To quote
from the method Javadoc.
> This method blocks until input data is available, end of file is
detected, or an exception is thrown.
> If no byte is available because the stream is at end of file, the
value {@code -1} is returned; otherwise, at least one byte is read and
stored into {@code b}.
Cheers
Philippe
Hi Philippe,
You are right about the readNBytes method itself. I was talking about
the read(byte[], int, int) method that is used internally by readNBytes.
That method may return 0 before EOF, and if it does then readNBytes
returns before it should.