Methods Summary |
---|
public static java.nio.channels.ReadableByteChannel | newChannel(java.io.InputStream inputStream)Returns a readable channel on the given input stream. The resulting
channel has the following properties:
- If the channel is closed, then the underlying stream is closed as
well.
- It is not buffered.
return new ReadableByteChannelImpl(inputStream);
|
public static java.nio.channels.WritableByteChannel | newChannel(java.io.OutputStream outputStream)Returns a writable channel on the given output stream.
The resulting channel has following properties:
- If the channel is closed, then the underlying stream is closed as
well.
- It is not buffered.
return new WritableByteChannelImpl(outputStream);
|
public static java.io.InputStream | newInputStream(java.nio.channels.ReadableByteChannel channel)Returns an input stream on the given channel. The resulting stream has
the following properties:
- If the stream is closed, then the underlying channel is closed as
well.
- It is thread safe.
- It throws an {@link IllegalBlockingModeException} if the channel is
in non-blocking mode and {@code read} is called.
- Neither {@code mark} nor {@code reset} is supported.
- It is not buffered.
return new ReadableByteChannelInputStream(channel);
|
public static java.io.OutputStream | newOutputStream(java.nio.channels.WritableByteChannel channel)Returns an output stream on the given channel. The resulting stream has
the following properties:
- If the stream is closed, then the underlying channel is closed as
well.
- It is thread safe.
- It throws an {@link IllegalBlockingModeException} if the channel is
in non-blocking mode and {@code write} is called.
- It is not buffered.
return new WritableByteChannelOutputStream(channel);
|
public static java.io.Reader | newReader(java.nio.channels.ReadableByteChannel channel, java.nio.charset.CharsetDecoder decoder, int minBufferCapacity)Returns a reader that decodes bytes from a channel.
return new ByteChannelReader(
new ReaderInputStream(channel), decoder,
minBufferCapacity);
|
public static java.io.Reader | newReader(java.nio.channels.ReadableByteChannel channel, java.lang.String charsetName)Returns a reader that decodes bytes from a channel. This method creates a
reader with a buffer of default size.
return newReader(channel, Charset.forName(charsetName).newDecoder(), -1);
|
public static java.io.Writer | newWriter(java.nio.channels.WritableByteChannel channel, java.nio.charset.CharsetEncoder encoder, int minBufferCapacity)Returns a writer that encodes characters with the specified
{@code encoder} and sends the bytes to the specified channel.
return new ByteChannelWriter(new WritableByteChannelOutputStream(
channel), encoder, minBufferCapacity);
|
public static java.io.Writer | newWriter(java.nio.channels.WritableByteChannel channel, java.lang.String charsetName)Returns a writer that encodes characters with the specified
{@code encoder} and sends the bytes to the specified channel. This method
creates a writer with a buffer of default size.
return newWriter(channel, Charset.forName(charsetName).newEncoder(), -1);
|
static java.nio.ByteBuffer | wrapByteBuffer(byte[] bytes, int offset, int length)
ByteBuffer buffer = ByteBuffer.wrap(bytes);
int newLimit = offset + length <= buffer.capacity() ? offset + length
: buffer.capacity();
buffer.limit(newLimit);
buffer.position(offset);
return buffer;
|