Name: sgC58550 Date: 03/20/97
The following code is from the source file for java.io.InputStream:
public long skip(long n) throws IOException {
/* ensure that the number is a positive int */
byte data[] = new byte[(int) (n & 0xEFFFFFFF)];
return read(data);
}
First, shouldn't that be 0x7FFFFFFF (not that anyone is likely to need to skip that many bytes)?
Second, it seems horribly inefficient to allocate a large array to hold the data I am discarding.
Wouldn't it be better to read the data and discard the bytes in a loop?
company - , email - ###@###.###
======================================================================
- duplicates
-
JDK-4076231 source code error in bit mask.
- Closed
-
JDK-4032572 java.io.InputStream.skip() can throw NegativeArraySizeException or return -1
- Closed