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

Alan Bateman Alan.Bateman at oracle.com
Thu Apr 23 14:41:09 UTC 2015


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.

-Alan



More information about the core-libs-dev mailing list