Hi,
On 01/19/2018 08:49 PM, Roger Riggs wrote:
Hi Brian,
Looks good,
A pre-existing typo:
line 67 "{@code skip()}" should be "{@code skip(*long*)}".
Since the public readNBytes suffices for readAllBytes, I would rename
the private readAtMostNBytes
to readNBytes and avoid the duplication of javadoc.
Keeping the existing readAllBytes before readNBytes in the source file
will make the diff easier to follow
and the methods be in alphabetical order.
Thanks, Roger
The delegation to public method (readAllBytes -> readNBytes) should then
be documented so that subclasses know that overriding readNBytes, if
needed, is sufficient. (likewise read(byte[]) which delegates to
read(byte[], int, int) which then delegates to read() - these
delegations are historically known and are part of the de-facto
specification on which many subclasses depend).
Perhaps, in a different issue, the delegation among all methods in
InputStream (and OutputStream) could be documented as @implSpec?
Regards, Peter
On 1/17/2018 11:24 AM, Brian Burkhalter wrote:
The proposed change has been modified to replace the two methods
byte[] InputStream.readAllBytes(int) // reads at most ‘len’ bytes
byte[] InputStream.readNBytes(int) // reads exactly ‘len’ bytes or
throws IOException
with a single method
byte[] InputStream.readNBytes(int) // reads at most ‘len’ bytes
A negative value of ‘len’ will now cause an IllegalArgumentException
instead of an IndexOutOfBoundsException. Also some verbiage has been
improved.
http://cr.openjdk.java.net/~bpb/8139206/webrev.01/
Thanks,
Brian
On Jan 16, 2018, at 11:17 AM, Brian Burkhalter
<brian.burkhal...@oracle.com> wrote:
https://bugs.openjdk.java.net/browse/JDK-8139206
http://cr.openjdk.java.net/~bpb/8139206/webrev.00/
This change would add a new method “byte[]
InputStream.readNBytes(int len)” which would read up to at most
‘len’ bytes from the stream and return them in an internally
allocated array.