Java.Nio.Channels Namespace

Defines channels for I/O operations, including file and socket channels, and selectors for multiplexed non-blocking I/O.

Classes

Name Description
AcceptPendingException

Unchecked exception thrown when an attempt is made to initiate an accept operation on a channel and a previous accept operation has not completed.

AlreadyBoundException

Unchecked exception thrown when an attempt is made to bind the socket a network oriented channel that is already bound.

AlreadyConnectedException

Unchecked exception thrown when an attempt is made to connect a SocketChannel that is already connected.

AsynchronousChannelGroup

A grouping of asynchronous channels for the purpose of resource sharing.

AsynchronousCloseException

Checked exception received by a thread when another thread closes the channel or the part of the channel upon which it is blocked in an I/O operation.

AsynchronousFileChannel

An asynchronous channel for reading, writing, and manipulating a file.

AsynchronousServerSocketChannel

An asynchronous channel for stream-oriented listening sockets.

AsynchronousSocketChannel

An asynchronous channel for stream-oriented connecting sockets.

CancelledKeyException

Unchecked exception thrown when an attempt is made to use a selection key that is no longer valid.

Channels

Utility methods for channels and streams.

ClosedByInterruptException

Checked exception received by a thread when another thread interrupts it while it is blocked in an I/O operation upon a channel.

ClosedChannelException

Checked exception thrown when an attempt is made to invoke or complete an I/O operation upon channel that is closed, or at least closed to that operation.

ClosedSelectorException

Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a closed selector.

ConnectionPendingException

Unchecked exception thrown when an attempt is made to connect a SocketChannel for which a non-blocking connection operation is already in progress.

DatagramChannel

A selectable channel for datagram-oriented sockets.

FileChannel

A channel for reading, writing, mapping, and manipulating a file.

FileChannel.MapMode

A typesafe enumeration for file-mapping modes.

FileLock

A token representing a lock on a region of a file.

FileLockInterruptionException

Checked exception received by a thread when another thread interrupts it while it is waiting to acquire a file lock.

IGatheringByteChannelExtensions

Provides task-based extension methods for writing bytes from a sequence of buffers.

IllegalBlockingModeException

Unchecked exception thrown when a blocking-mode-specific operation is invoked upon a channel in the incorrect blocking mode.

IllegalChannelGroupException

Unchecked exception thrown when an attempt is made to open a channel in a group that was not created by the same provider.

IllegalSelectorException

Unchecked exception thrown when an attempt is made to register a channel with a selector that was not created by the provider that created the channel.

InterruptedByTimeoutException

Checked exception received by a thread when a timeout elapses before an asynchronous operation completes.

IReadableByteChannelExtensions

Provides a task-based extension method for reading bytes from a readable channel.

IScatteringByteChannelExtensions

Provides task-based extension methods for reading bytes into a sequence of buffers.

IWritableByteChannelExtensions

Provides a task-based extension method for writing bytes to a writable channel.

MembershipKey

A token representing the membership of an Internet Protocol (IP) multicast group.

NoConnectionPendingException

Unchecked exception thrown when the SocketChannel#finishConnect finishConnect method of a SocketChannel is invoked without first successfully invoking its SocketChannel#connect connect method.

NonReadableChannelException

Unchecked exception thrown when an attempt is made to read from a channel that was not originally opened for reading.

NonWritableChannelException

Unchecked exception thrown when an attempt is made to write to a channel that was not originally opened for writing.

NotYetBoundException

Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a server socket channel that is not yet bound.

NotYetConnectedException

Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a socket channel that is not yet connected.

OverlappingFileLockException

Unchecked exception thrown when an attempt is made to acquire a lock on a region of a file that overlaps a region already locked by the same Java virtual machine, or when another thread is already waiting to lock an overlapping region of the same file.

Pipe

A pair of channels that implements a unidirectional pipe.

Pipe.SinkChannel

A channel representing the writable end of a Pipe.

Pipe.SourceChannel

A channel representing the readable end of a Pipe.

ReadPendingException

Unchecked exception thrown when an attempt is made to read from an asynchronous socket channel and a previous read has not completed.

SelectableChannel

A channel that can be multiplexed via a Selector.

SelectionKey

A token representing the registration of a SelectableChannel with a Selector.

Selector

A multiplexor of SelectableChannel objects.

ServerSocketChannel

A selectable channel for stream-oriented listening sockets.

ShutdownChannelGroupException

Unchecked exception thrown when an attempt is made to construct a channel in a group that is shutdown or the completion handler for an I/O operation cannot be invoked because the channel group has terminated.

SocketChannel

A selectable channel for stream-oriented connecting sockets.

UnresolvedAddressException

Unchecked exception thrown when an attempt is made to invoke a network operation upon an unresolved socket address.

UnsupportedAddressTypeException

Unchecked exception thrown when an attempt is made to bind or connect to a socket address of a type that is not supported.

WritePendingException

Unchecked exception thrown when an attempt is made to write to an asynchronous socket channel and a previous write has not completed.

Interfaces

Name Description
IAsynchronousByteChannel

An asynchronous channel that can read and write bytes.

IAsynchronousChannel

A channel that supports asynchronous I/O operations.

IByteChannel

A channel that can read and write bytes.

IChannel

A nexus for I/O operations.

ICompletionHandler

A handler for consuming the result of an asynchronous I/O operation.

IGatheringByteChannel

A channel that can write bytes from a sequence of buffers.

IInterruptibleChannel

A channel that can be asynchronously closed and interrupted.

IReadableByteChannel

A channel that can read bytes.

IScatteringByteChannel

A channel that can read bytes into a sequence of buffers.

ISeekableByteChannel

A byte channel that maintains a current position and allows the position to be changed.

IWritableByteChannel

A channel that can write bytes.

Enums

Name Description
Operations

Enumerates values returned by several types and taken as a parameter of several types.

Remarks

Channels read bytes into buffers and write bytes from buffers. Scattering reads use a sequence of destination buffers; gathering writes use a sequence of source buffers. File channels also support file positions, locks, memory mapping, and transfers between channels. Selectors monitor registered channels for non-blocking I/O readiness.

The .NET methods with an Async suffix on synchronous channel classes, and the channel extension methods, run the matching synchronous operation with System.Threading.Tasks.Task.Run. They retain that operation's blocking-mode behavior and result. These wrappers are separate from the Java asynchronous file and socket channel APIs.

See the Android channel package documentation and the .NET binding generator's method task wrappers and extension task wrappers.