2003-04-06 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Sun, 6 Apr 2003 15:51:06 +0000 (15:51 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Sun, 6 Apr 2003 15:51:06 +0000 (15:51 +0000)
* java/io/FileInputStream.java
(skip): Renamed some variables to match classpath, added
checks from classpath.

From-SVN: r65300

libjava/ChangeLog
libjava/java/io/FileInputStream.java

index 506882d..3390db7 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-06  Michael Koch  <konqueror@gmx.de>
+
+       * java/io/FileInputStream.java
+       (skip): Renamed some variables to match classpath, added
+       checks from classpath.
+
 2003-03-31  Michael Koch  <konqueror@gmx.de>
 
        * javax/swing/AbstractAction.java
index 50abeaa..b49922e 100644 (file)
@@ -268,11 +268,18 @@ public class FileInputStream extends InputStream
    *
    * @exception IOException If an error occurs
    */
-  public long skip(long n) throws IOException
+  public long skip (long numBytes) throws IOException
   {
-    long startPos = fd.getFilePointer();
-    long endPos = fd.seek(n, FileDescriptor.CUR, true);
-    return endPos - startPos;
+    if (numBytes < 0)
+      throw new IllegalArgumentException ( "Can't skip negative bytes: " +
+                                           numBytes);
+
+    if (numBytes == 0)
+      return 0;
+    
+    long curPos = fd.getFilePointer ();
+    long newPos = fd.seek (numBytes, FileDescriptor.CUR, true);
+    return newPos - curPos;
   }
 
   /**