diff options
| author | Tom Tromey <tromey@redhat.com> | 2006-12-15 19:32:31 +0000 |
|---|---|---|
| committer | Tom Tromey <tromey@redhat.com> | 2006-12-15 19:32:31 +0000 |
| commit | 9d204549dc831c315b7001518b51f6cfa5771b7a (patch) | |
| tree | 68fe090c33cd9270205cdb226fe355bcba110147 /gnu/java/nio/ChannelInputStream.java | |
| parent | 6c66f66fa80b8577e948722cfdc1deea6a4d0619 (diff) | |
| download | classpath-9d204549dc831c315b7001518b51f6cfa5771b7a.tar.gz | |
PR classpath/29526:
* gnu/java/nio/ChannelInputStream.java (read): New overload.
(read): Mask return result.
Diffstat (limited to 'gnu/java/nio/ChannelInputStream.java')
| -rw-r--r-- | gnu/java/nio/ChannelInputStream.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gnu/java/nio/ChannelInputStream.java b/gnu/java/nio/ChannelInputStream.java index 675a62f3d..f56536d65 100644 --- a/gnu/java/nio/ChannelInputStream.java +++ b/gnu/java/nio/ChannelInputStream.java @@ -59,6 +59,16 @@ public final class ChannelInputStream extends InputStream this.ch = ch; } + public int read(byte[] buf, int off, int len) throws IOException + { + if (ch instanceof SelectableChannel + && (! ((SelectableChannel) ch).isBlocking())) + throw new IllegalBlockingModeException(); + + ByteBuffer b = ByteBuffer.wrap(buf, off, len); + return ch.read(b); + } + public int read() throws IOException { if (ch instanceof SelectableChannel @@ -74,6 +84,6 @@ public final class ChannelInputStream extends InputStream if (result == 0) throw new IOException("Could not read from channel"); - return buffer.get(0); + return buffer.get(0) & 0xff; } } |
