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 /java/io/RandomAccessFile.java | |
parent | 3f93e18604951f8d8d8456dc46c559b8a0e4d834 (diff) | |
download | classpath-374a78f148c6789d4ea1d8a2cb0f46988d695e8c.tar.gz |
java/io/RandomAccessFile: corrected skipBytes() to stop at EOF
Diffstat (limited to 'java/io/RandomAccessFile.java')
-rw-r--r-- | java/io/RandomAccessFile.java | 7 |
1 files changed, 5 insertions, 2 deletions
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); } /*************************************************************************/ |