java.nio.channels
Interface Channel

All Superinterfaces:
Closeable sample code for java.io.Closeable definition code for java.io.Closeable
All Known Subinterfaces:
ByteChannel sample code for java.nio.channels.ByteChannel definition code for java.nio.channels.ByteChannel , GatheringByteChannel sample code for java.nio.channels.GatheringByteChannel definition code for java.nio.channels.GatheringByteChannel , InterruptibleChannel sample code for java.nio.channels.InterruptibleChannel definition code for java.nio.channels.InterruptibleChannel , ReadableByteChannel sample code for java.nio.channels.ReadableByteChannel definition code for java.nio.channels.ReadableByteChannel , ScatteringByteChannel sample code for java.nio.channels.ScatteringByteChannel definition code for java.nio.channels.ScatteringByteChannel , WritableByteChannel sample code for java.nio.channels.WritableByteChannel definition code for java.nio.channels.WritableByteChannel
All Known Implementing Classes:
AbstractInterruptibleChannel sample code for java.nio.channels.spi.AbstractInterruptibleChannel definition code for java.nio.channels.spi.AbstractInterruptibleChannel , AbstractSelectableChannel sample code for java.nio.channels.spi.AbstractSelectableChannel definition code for java.nio.channels.spi.AbstractSelectableChannel , DatagramChannel sample code for java.nio.channels.DatagramChannel definition code for java.nio.channels.DatagramChannel , FileChannel sample code for java.nio.channels.FileChannel definition code for java.nio.channels.FileChannel , Pipe.SinkChannel sample code for java.nio.channels.Pipe.SinkChannel definition code for java.nio.channels.Pipe.SinkChannel , Pipe.SourceChannel sample code for java.nio.channels.Pipe.SourceChannel definition code for java.nio.channels.Pipe.SourceChannel , SelectableChannel sample code for java.nio.channels.SelectableChannel definition code for java.nio.channels.SelectableChannel , ServerSocketChannel sample code for java.nio.channels.ServerSocketChannel definition code for java.nio.channels.ServerSocketChannel , SocketChannel sample code for java.nio.channels.SocketChannel definition code for java.nio.channels.SocketChannel

public interface Channel
extends Closeable sample code for java.io.Closeable definition code for java.io.Closeable

A nexus for I/O operations.

A channel represents an open connection to an entity such as a hardware device, a file, a network socket, or a program component that is capable of performing one or more distinct I/O operations, for example reading or writing.

A channel is either open or closed. A channel is open upon creation, and once closed it remains closed. Once a channel is closed, any attempt to invoke an I/O operation upon it will cause a ClosedChannelException sample code for java.nio.channels.ClosedChannelException definition code for java.nio.channels.ClosedChannelException to be thrown. Whether or not a channel is open may be tested by invoking its isOpen sample code for java.nio.channels.Channel.isOpen() definition code for java.nio.channels.Channel.isOpen() method.

Channels are, in general, intended to be safe for multithreaded access as described in the specifications of the interfaces and classes that extend and implement this interface.

Since:
1.4

Method Summary
 void close sample code for java.nio.channels.Channel.close() definition code for java.nio.channels.Channel.close() ()
          Closes this channel.
 boolean isOpen sample code for java.nio.channels.Channel.isOpen() definition code for java.nio.channels.Channel.isOpen() ()
          Tells whether or not this channel is open.
 

Method Detail

isOpen sample code for java.nio.channels.Channel.isOpen() definition code for java.nio.channels.Channel.isOpen()

boolean isOpen()
Tells whether or not this channel is open.

Returns:
true if, and only if, this channel is open

close sample code for java.nio.channels.Channel.close() definition code for java.nio.channels.Channel.close()

void close()
           throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Closes this channel.

After a channel is closed, any further attempt to invoke I/O operations upon it will cause a ClosedChannelException sample code for java.nio.channels.ClosedChannelException definition code for java.nio.channels.ClosedChannelException to be thrown.

If this channel is already closed then invoking this method has no effect.

This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.

Specified by:
close sample code for java.io.Closeable.close() definition code for java.io.Closeable.close() in interface Closeable sample code for java.io.Closeable definition code for java.io.Closeable
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If an I/O error occurs