FileInputStream.skip() fix
Bryce McKinlay
bryce@waitaki.otago.ac.nz
Sun Mar 24 18:56:00 GMT 2002
FileInputStream.skip() is supposed to return the actual number of bytes
skipped, but ours was returning the current position in the file. This
patch fixes.
Bryce.
* java/io/FileInputStream.java (skip): Call fd.getFilePointer() and
calculate correct number of bytes skipped.
Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileInputStream.java,v
retrieving revision 1.6
diff -u -r1.6 FileInputStream.java
--- FileInputStream.java 2001/08/02 23:46:39 1.6
+++ FileInputStream.java 2002/03/25 01:55:26
@@ -88,6 +88,8 @@
public long skip(long n) throws IOException
{
- return n <= 0 ? 0 : fd.seek(n, FileDescriptor.CUR, true);
+ long startPos = fd.getFilePointer();
+ long endPos = fd.seek(n, FileDescriptor.CUR, true);
+ return endPos - startPos;
}
}
More information about the Java-patches
mailing list