RFR [9] Add blocking bulk read to java.io.InputStream

Alan Bateman Alan.Bateman at oracle.com
Fri Apr 24 06:03:05 UTC 2015

On 23/04/2015 21:22, Remi Forax wrote:
> On 04/23/2015 04:41 PM, Alan Bateman wrote:
>> On 23/04/2015 13:22, Remi Forax wrote:
>>> I think the name readBytes is not very informative and the name is 
>>> too close to read + an array of bytes,
>>> we can not use readFully (from DataInput/DataInputStream) because 
>>> instead of returning the number of bytes read, it throws a 
>>> EOFException if the end of the stream is reached.
>>> so what about readAllBytes ?
>>> (There is also a readAllBytes in java.nio.file.Files that has an 
>>> equivalent semantics).
>> For pure convenience then a readAllBytes() that returns a byte[] 
>> would be useful. It avoids all the issues around short reads too, and 
>> of course easy to specify that the input stream would be left in an 
>> inconsistent state if there are any exceptions thrown.
> you mean readAllBytes on Files or readAllBytes on InputStream ?
I mean on InputStream, for the cases where want to read to EOF. There 
are also cases where you want readNbytes and there are variations of 
that where you specify the byte[] to copy into or just have it returned. 
So I suspect we'll end up with more than one method but I hope not more 
than two.


More information about the core-libs-dev mailing list