diff options
author | Daryl Lee <dlee@altaregos.com> | 2002-12-27 18:40:09 +0000 |
---|---|---|
committer | Daryl Lee <dlee@altaregos.com> | 2002-12-27 18:40:09 +0000 |
commit | 374a78f148c6789d4ea1d8a2cb0f46988d695e8c (patch) | |
tree | fbc3864b6b4247172028a93ef57801d6e6d3818a | |
parent | 3f93e18604951f8d8d8456dc46c559b8a0e4d834 (diff) | |
download | classpath-374a78f148c6789d4ea1d8a2cb0f46988d695e8c.tar.gz |
java/io/RandomAccessFile: corrected skipBytes() to stop at EOF
-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); } /*************************************************************************/ |