From af5fcbd02e4a9f17a53fc27dd90db17a79ab96f3 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Sun, 6 Apr 2003 15:51:06 +0000 Subject: 2003-04-06 Michael Koch * java/io/FileInputStream.java (skip): Renamed some variables to match classpath, added checks from classpath. From-SVN: r65300 --- libjava/java/io/FileInputStream.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'libjava/java/io/FileInputStream.java') diff --git a/libjava/java/io/FileInputStream.java b/libjava/java/io/FileInputStream.java index 50abeaa..b49922e 100644 --- a/libjava/java/io/FileInputStream.java +++ b/libjava/java/io/FileInputStream.java @@ -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; } /** -- cgit v1.1