Build 1.0_r1(from source)

java.nio.channels
Class Channels

java.lang.Object
  extended by java.nio.channels.Channels

public final class Channels
extends Object

This class provides several utilities to get I/O streams from channels.


Method Summary
static ReadableByteChannel newChannel(InputStream inputStream)
          Returns a channel on the given input stream
static WritableByteChannel newChannel(OutputStream outputStream)
          Returns a channel on the given output stream
static InputStream newInputStream(ReadableByteChannel channel)
          Returns an input stream on the given channel
static OutputStream newOutputStream(WritableByteChannel channel)
          Returns an output stream on the given channel
static Reader newReader(ReadableByteChannel channel, CharsetDecoder decoder, int minBufferCapacity)
          Returns a reader that decodes bytes from a channel.
static Reader newReader(ReadableByteChannel channel, String charsetName)
          Returns a reader that decodes bytes from a channel.
static Writer newWriter(WritableByteChannel channel, CharsetEncoder encoder, int minBufferCapacity)
          Returns a writer that encodes characters by encoder and output bytes to a channel.
static Writer newWriter(WritableByteChannel channel, String charsetName)
          Returns a writer that encodes characters by encoder and output bytes to a channel.
(package private) static ByteBuffer wrapByteBuffer(byte[] bytes, int offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInputStream

public static InputStream newInputStream(ReadableByteChannel channel)
Returns an input stream on the given channel

Parameters:
channel - The channel to be wrapped in an InputStream.
Returns:
an InputStream that takes bytes from the given byte channel.

newOutputStream

public static OutputStream newOutputStream(WritableByteChannel channel)
Returns an output stream on the given channel

Parameters:
channel - the channel to be wrapped in an OutputStream.
Returns:
an OutputStream that puts bytes onto the given byte channel.

newChannel

public static ReadableByteChannel newChannel(InputStream inputStream)
Returns a channel on the given input stream

Parameters:
inputStream - the stream to be wrapped in a byte channel.
Returns:
a byte channel that reads bytes from the input stream.

newChannel

public static WritableByteChannel newChannel(OutputStream outputStream)
Returns a channel on the given output stream

Parameters:
outputStream - the stream to be wrapped in a byte channel.
Returns:
a byte channel that writes bytes to the output stream.

newReader

public static Reader newReader(ReadableByteChannel channel,
                               CharsetDecoder decoder,
                               int minBufferCapacity)
Returns a reader that decodes bytes from a channel.

Parameters:
channel - Channel to be read.
decoder - Charset decoder to be used.
minBufferCapacity - The minimum size of byte buffer, -1 means to use default size.
Returns:
The reader.

newReader

public static Reader newReader(ReadableByteChannel channel,
                               String charsetName)
Returns a reader that decodes bytes from a channel.

Parameters:
channel - Channel to be read.
charsetName - Name of charset.
Returns:
The reader.

newWriter

public static Writer newWriter(WritableByteChannel channel,
                               CharsetEncoder encoder,
                               int minBufferCapacity)
Returns a writer that encodes characters by encoder and output bytes to a channel.

Parameters:
channel - Channel to be written.
encoder - Charset decoder to be used.
minBufferCapacity - The minimum size of byte buffer, -1 means to use default size.
Returns:
The writer.

newWriter

public static Writer newWriter(WritableByteChannel channel,
                               String charsetName)
Returns a writer that encodes characters by encoder and output bytes to a channel.

Parameters:
channel - Channel to be written.
charsetName - Name of charset.
Returns:
The writer.

wrapByteBuffer

static ByteBuffer wrapByteBuffer(byte[] bytes,
                                 int offset,
                                 int length)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature