Channel
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
AbstractInterruptibleChannel,
AbstractSelectableChannel,
AsynchronousByteChannel,
AsynchronousChannel,
AsynchronousFileChannel,
AsynchronousServerSocketChannel,
AsynchronousSocketChannel,
ByteChannel,
DatagramChannel,
FileChannel,
GatheringByteChannel,
InterruptibleChannel,
MulticastChannel,
NetworkChannel,
Pipe.SinkChannel,
and
8 others.
|
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
to be thrown. Whether or not a channel is open may be tested by invoking
its 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.
Public Method Summary
abstract
void
|
close()
Closes this channel.
|
abstract
boolean
|
isOpen()
Tells whether or not this channel is open.
|
Inherited Method Summary
From interface
java.io.Closeable
abstract
void
|
close()
Closes this stream and releases any system resources associated
with it.
|
Public Methods
public
abstract
void
close
()
Closes this channel.
After a channel is closed, any further attempt to invoke I/O
operations upon it will cause a 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.
public
abstract
boolean
isOpen
()
Tells whether or not this channel is open.
Returns
- true if, and only if, this channel is open
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eChannel\u003c/code\u003e interface represents an open connection to an entity like a file, network socket, or hardware device, enabling I/O operations.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eChannel\u003c/code\u003e can be either open or closed, with attempts to perform I/O on a closed channel resulting in a \u003ccode\u003eClosedChannelException\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eChannel\u003c/code\u003e interface provides methods to close the channel (\u003ccode\u003eclose()\u003c/code\u003e) and to check if it's open (\u003ccode\u003eisOpen()\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eChannels are generally designed to be thread-safe for multithreaded access.\u003c/p\u003e\n"],["\u003cp\u003eMany types of channels exist, including \u003ccode\u003eFileChannel\u003c/code\u003e, \u003ccode\u003eSocketChannel\u003c/code\u003e, \u003ccode\u003eDatagramChannel\u003c/code\u003e, and asynchronous variations, each catering to specific I/O needs.\u003c/p\u003e\n"]]],[],null,[]]