Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Channel

public interface Channel
implements Closeable

java.nio.channels.Channel
Known Indirect Subclasses


A channel is a conduit to I/O services covering such items as files, sockets, hardware devices, I/O ports or some software component.

Channels are open upon creation, and can be closed explicitly. Once a channel is closed it cannot be re-opened, and any attempts to perform I/O operations on the closed channel result in a ClosedChannelException.

Particular implementations or sub-interfaces of Channel dictate whether they are thread-safe or not.

Summary

Public methods

abstract void close()

Closes an open channel.

abstract boolean isOpen()

Returns true if this channel is open.

Inherited methods

From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public methods

close

Added in API level 1
void close ()

Closes an open channel. If the channel is already closed then this method has no effect. If there is a problem with closing the channel then the method throws an IOException and the exception contains reasons for the failure.

If an attempt is made to perform an operation on a closed channel then a ClosedChannelException will be thrown on that attempt.

If multiple threads attempt to simultaneously close a channel, then only one thread will run the closure code, and others will be blocked until the first returns.

Throws
IOException if a problem occurs closing the channel.

isOpen

Added in API level 1
boolean isOpen ()

Returns true if this channel is open.

Returns
boolean
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.