java.nio.channels

Class Channels


public final class Channels
extends Object

Since:
1.4

Method Summary

static ReadableByteChannel
newChannel(InputStream in)
Constructs a channel that reads bytes from the given stream.
static WritableByteChannel
newChannel(OutputStream out)
Constructs a channel that writes bytes to the given stream.
static InputStream
newInputStream(ReadableByteChannel ch)
Constructs a stream that reads bytes from the given channel.
static OutputStream
newOutputStream(WritableByteChannel ch)
Constructs a stream that writes bytes to the given channel.
static Reader
newReader(ReadableByteChannel ch, String csName)
Constructs a reader that decodes bytes from the given channel according to the named charset.
static Reader
newReader(ReadableByteChannel ch, CharsetDecoder dec, int minBufferCap)
Constructs a reader that decodes bytes from the given channel using the given decoder.
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.
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.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

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,
                               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.

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.

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.

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.

Channels.java -- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.