diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | java/io/RandomAccessFile.java | 7 |
2 files changed, 8 insertions, 3 deletions
@@ -1,5 +1,7 @@ -2002-12-25 Daryl Lee <dolee@sources.redhat.com> +2002-12-27 Daryl Lee <dolee@sources.redhat.com> + * java/io/RandomAccessFile.java: corrected skipBytes() to stop at EOF +2002-12-25 Daryl Lee <dolee@sources.redhat.com> * java/io/PipedOutputStream.java: corrected connect(); test to check if already connected was invalid. diff --git a/java/io/RandomAccessFile.java b/java/io/RandomAccessFile.java index 7d15e76a3..7703ca5a8 100644 --- a/java/io/RandomAccessFile.java +++ b/java/io/RandomAccessFile.java @@ -921,9 +921,12 @@ skipBytes(int n) throws EOFException, IOException if (n <= 0) return(0); - long total_skipped = skipInternal(native_fd, n); + long file_length = this.length(); + long file_position = this.getFilePointer(); + int skip_length = (int) Math.min(n, file_length - file_position); + long total_skipped = skipInternal(native_fd, skip_length); - return((int)n); + return((int)total_skipped); } /*************************************************************************/ |