diff options
author | Aaron M. Renn <arenn@urbanophile.com> | 1998-12-31 00:35:20 +0000 |
---|---|---|
committer | Aaron M. Renn <arenn@urbanophile.com> | 1998-12-31 00:35:20 +0000 |
commit | 069a166e6bae6c6bb1c3951776db23ec0191b072 (patch) | |
tree | a0ad783574f25b39f26a5ed55b4c562647a45e31 /java/io/RandomAccessFile.java | |
parent | 2c356bbbae062032fa2454d5692de97651f62bec (diff) | |
download | classpath-069a166e6bae6c6bb1c3951776db23ec0191b072.tar.gz |
Ensure we always return -1 on end of file
Diffstat (limited to 'java/io/RandomAccessFile.java')
-rw-r--r-- | java/io/RandomAccessFile.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/java/io/RandomAccessFile.java b/java/io/RandomAccessFile.java index 049358548..acfb4578b 100644 --- a/java/io/RandomAccessFile.java +++ b/java/io/RandomAccessFile.java @@ -305,7 +305,7 @@ read() throws IOException byte[] buf = new byte[1]; int rc = readInternal(native_fd, buf, 0, buf.length); - if (rc == -1) + if (rc == 0) return(-1); return(buf[0] & 0xFF); @@ -327,7 +327,11 @@ read() throws IOException public int read(byte[] buf) throws IOException { - return(readInternal(native_fd, buf, 0, buf.length)); + int rc = readInternal(native_fd, buf, 0, buf.length); + if (rc == 0) + return(-1); + else + return(rc); } /*************************************************************************/ @@ -347,7 +351,11 @@ read(byte[] buf) throws IOException public int read(byte[] buf, int offset, int len) throws IOException { - return(readInternal(native_fd, buf, offset, len)); + int rc = readInternal(native_fd, buf, 0, buf.length); + if (rc == 0) + return(-1); + else + return(rc); } /*************************************************************************/ |