CLDC 8 (b75)

Package java.nio.channels

Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files.

See: Description

Package java.nio.channels Description

Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files.

Channels

Description

Channel A nexus for I/O operations
  ReadableByteChannel Can read into a buffer
  WritableByteChannel Can write from a buffer
  ByteChannel Can read/write to/from a buffer
    SeekableByteChannel A ByteChannel connected to an entity that contains a variable-length sequence of bytes

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. As specified in the Channel interface, channels are either open or closed, and they are both asynchronously closeable and interruptible.

The Channel interface is extended by several other interfaces.

The ReadableByteChannel interface specifies a read method that reads bytes from the channel into a buffer; similarly, the WritableByteChannel interface specifies a write method that writes bytes from a buffer to the channel. The ByteChannel interface unifies these two interfaces for the common case of channels that can both read and write bytes. The SeekableByteChannel interface extends the ByteChannel interface with methods to query and modify the channel's current position, and its size.

The FileChannel class supports the usual operations of reading bytes from, and writing bytes to, a channel connected to a file, as well as those of querying and modifying the current file position and truncating the file to a specific size. Finally, it defines methods for forcing updates to the file to be written to the storage device that contains it, for efficiently transferring bytes between the file and other channels, and for mapping a region of the file directly into memory.

A FileChannel is created by invoking one of its static open methods to return a file channel connected to the same underlying file as the java.io class.


Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.

Since:
1.4, CLDC1.8
CLDC 8 (b75)
10-February-2014 08:32

Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved. Use of this specification is subject to license terms.