java.nio.channels

Class Channels

public final class Channels extends Object

Since: 1.4

Method Summary
static ReadableByteChannelnewChannel(InputStream in)
Constructs a channel that reads bytes from the given stream.
static WritableByteChannelnewChannel(OutputStream out)
Constructs a channel that writes bytes to the given stream.
static InputStreamnewInputStream(ReadableByteChannel ch)
Constructs a stream that reads bytes from the given channel.
static OutputStreamnewOutputStream(WritableByteChannel ch)
Constructs a stream that writes bytes to the given channel.
static ReadernewReader(ReadableByteChannel ch, CharsetDecoder dec, int minBufferCap)
Constructs a reader that decodes bytes from the given channel using the given decoder.
static ReadernewReader(ReadableByteChannel ch, String csName)
Constructs a reader that decodes bytes from the given channel according to the named charset.
static WriternewWriter(WritableByteChannel ch, CharsetEncoder enc, int minBufferCap)
Constructs a writer that encodes characters using the given encoder and writes the resulting bytes to the given channel.
static WriternewWriter(WritableByteChannel ch, String csName)
Constructs a writer that encodes characters according to the named charset and writes the resulting bytes to the given channel.

Method Detail

newChannel

public static ReadableByteChannel newChannel(InputStream in)
Constructs a channel that reads bytes from the given stream.

newChannel

public static WritableByteChannel newChannel(OutputStream out)
Constructs a channel that writes bytes to the given stream.

newInputStream

public static InputStream newInputStream(ReadableByteChannel ch)
Constructs a stream that reads bytes from the given channel.

newOutputStream

public static OutputStream newOutputStream(WritableByteChannel ch)
Constructs a stream that writes bytes to the given channel.

newReader

public static Reader newReader(ReadableByteChannel ch, CharsetDecoder dec, int minBufferCap)
Constructs a reader that decodes bytes from the given channel using the given decoder.

newReader

public static Reader newReader(ReadableByteChannel ch, String csName)
Constructs a reader that decodes bytes from the given channel according to the named charset.

Throws: UnsupportedCharsetException If no support for the named charset is available in this instance of the Java virtual machine.

newWriter

public static Writer newWriter(WritableByteChannel ch, CharsetEncoder enc, int minBufferCap)
Constructs a writer that encodes characters using the given encoder and writes the resulting bytes to the given channel.

newWriter

public static Writer newWriter(WritableByteChannel ch, String csName)
Constructs a writer that encodes characters according to the named charset and writes the resulting bytes to the given channel.

Throws: UnsupportedCharsetException If no support for the named charset is available in this instance of the Java virtual machine.