6516099: InputStream.skipFully(int k) to skip exactly k bytes

Brian Burkhalter brian.burkhalter at oracle.com
Wed Oct 24 19:56:01 UTC 2018


Hi Andrew,

Thanks for the suggestion. Will consider it for the final check-in.

Brian

> On Oct 24, 2018, at 12:39 PM, Andrew Luo <andrewluotechnologies at outlook.com> wrote:
> 
> I'm not a reviewer/committer but just a suggestion:
> 
> You can use assert to ensure "document" that skip(long) should never return negative (and also provide useful debugging when assertions are enabled), for example:
> 
> 586             long ns = skip(n);
> assert ns >= 0 : "skip(long) returned negative value " + ns;
> 587 
> 588             // If not enough skipped, read and discard bytes, failing on EOF
> 589             if (ns != n) {
> 590                 discardNBytes(n - ns, true);
> 591             }



More information about the core-libs-dev mailing list