[
https://issues.apache.org/jira/browse/IO-203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12842761#action_12842761
]
Sebb commented on IO-203:
-------------------------
I started out doing that, but as far as I could tell the default
implementations of skip call read() repeatedly until EOF anyway - so it would
just be repeating the code.
As to FileInputStream, I noticed that when I was trying to set up a test.
I've just confirmed that the behaviour is due to skip() rather than read() - in
other words it overrides the default skip() implementation.
So yes, it would after all be useful to have a "proper" skip implementation
that cannot be overridden.
How should count < 0 be handled?
At present Reader throws IAE, but InputStream just returns. I'd prefer to see
IAE for both.
> Add skipFully() method for InputStreams
> ---------------------------------------
>
> Key: IO-203
> URL: https://issues.apache.org/jira/browse/IO-203
> Project: Commons IO
> Issue Type: New Feature
> Components: Utilities
> Reporter: Sebb
> Fix For: 2.0
>
>
> The skip() method is not guaranteed to skip the requested number of bytes,
> even if there is more data available. This is particularly true of Buffered
> input streams.
> It would be useful to have a skip() method that keeps skipping until the
> required number of bytes have been read, or EOF was reached, in which case it
> should throw an Exception.
> [I'll add a patch later.]
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.