Skip to content

Most visited

Recently visited

navigation
Added in API level 1

WritableByteChannel

public interface WritableByteChannel
implements Channel

java.nio.channels.WritableByteChannel
Known Indirect Subclasses


A WritableByteChannel is a type of Channel that can write bytes.

Write operations are synchronous on a WritableByteChannel, that is, if a write is already in progress on the channel then subsequent writes will block until the first write completes. It is undefined whether non-write operations will block.

Summary

Public methods

abstract int write(ByteBuffer buffer)

Writes bytes from the given buffer to the channel.

Inherited methods

From interface java.nio.channels.Channel
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public methods

write

Added in API level 1
int write (ByteBuffer buffer)

Writes bytes from the given buffer to the channel.

The maximum number of bytes that will be written is the remaining() number of bytes in the buffer when the method invoked. The bytes will be written from the buffer starting at the buffer's position.

The call may block if other threads are also attempting to write on the same channel.

Upon completion, the buffer's position() is updated to the end of the bytes that were written. The buffer's limit() is unmodified.

Parameters
buffer ByteBuffer: the byte buffer containing the bytes to be written.
Returns
int the number of bytes actually written.
Throws
NonWritableChannelException if the channel was not opened for writing.
ClosedChannelException if the channel was already closed.
AsynchronousCloseException if another thread closes the channel during the write.
ClosedByInterruptException if another thread interrupt the calling thread during the write.
IOException another IO exception occurs, details are in the message.
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.