summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Marshall <csm@gnu.org>2006-09-25 06:49:18 +0000
committerCasey Marshall <csm@gnu.org>2006-09-25 06:49:18 +0000
commit5b29cb3bac033c7d851d692605c5f1d51563dc6d (patch)
tree939a413dc0bc0b49d0877e2d73a8c409687f4232
parent599f5e47f99635a93a0d350b2f06086b2c34d7ee (diff)
downloadclasspath-5b29cb3bac033c7d851d692605c5f1d51563dc6d.tar.gz
2006-09-24 Casey Marshall <csm@gnu.org>
* gnu/java/nio/FileChannelImpl.java (read): call `read' in a loop, don't use `readScattering.' (write): call `write' in a loop, don't use `writeGathering.'
-rw-r--r--ChangeLog6
-rw-r--r--gnu/java/nio/FileChannelImpl.java21
2 files changed, 25 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a7820414e..4b47b591c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-24 Casey Marshall <csm@gnu.org>
+
+ * gnu/java/nio/FileChannelImpl.java
+ (read): call `read' in a loop, don't use `readScattering.'
+ (write): call `write' in a loop, don't use `writeGathering.'
+
2006-09-24 Mark Wielaard <mark@klomp.org>
* configure.ac: Move -pedantic from WARNING to STRICT flags.
diff --git a/gnu/java/nio/FileChannelImpl.java b/gnu/java/nio/FileChannelImpl.java
index 419124050..42efcd0be 100644
--- a/gnu/java/nio/FileChannelImpl.java
+++ b/gnu/java/nio/FileChannelImpl.java
@@ -253,7 +253,18 @@ public final class FileChannelImpl extends FileChannel
public long read (ByteBuffer[] dsts, int offset, int length)
throws IOException
{
- return ch.readScattering(dsts, offset, length);
+ int n = offset + length;
+ long read = 0;
+ if (offset < 0 || length < 0 || n > dsts.length)
+ throw new ArrayIndexOutOfBoundsException();
+ for (int i = offset; i < n; i++)
+ {
+ int ret = read(dsts[i]);
+ if (ret == -1)
+ break;
+ read += ret;
+ }
+ return read;
}
public int write (ByteBuffer src) throws IOException
@@ -292,7 +303,13 @@ public final class FileChannelImpl extends FileChannel
public long write(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
- return ch.writeGathering(srcs, offset, length);
+ int n = offset + length;
+ long written = 0;
+ if (offset < 0 || length < 0 || n > srcs.length)
+ throw new ArrayIndexOutOfBoundsException();
+ for (int i = offset; i < n; i++)
+ written += write(srcs[i]);
+ return written;
}
public MappedByteBuffer map (FileChannel.MapMode mode,