FileInputStream negative skip
- by Peter Štibraný
I'm trying to find more about history of FileInputStream.skip(negative) operation. According to InputStream documentation:
If n is negative, no bytes are skipped.
It seems that implementation of FileInputStream from Sun used to throw IOException instead, which is now also documented in Javadoc:
If n is negative, an IOException is thrown, even though the skip method of the InputStream superclass does nothing in this case.
I just tried that, and found that FileInputStream.skip(-10) did in fact return -10! It didn't threw exception, it didn't even return 0, it returned -10. (I've tried with Java 1.5.0_22 from Sun, and Java 1.6.0_18 from Sun). Is this a known bug? Why hasn't it been fixed, or why documentation is kept the way it is? Can someone point me to some discussion about this issue? I can't find anything.