java.nio.channels · java.base · since Java 1.4
FileChannel
public abstract class FileChannel extends AbstractInterruptibleChannel
implements SeekableByteChannel, GatheringByteChannel, ScatteringByteChannelBlock-oriented file access: positional (thread-safe) reads/writes, memory mapping, locking, and zero-copy transferTo — the substrate of high-performance file I/O.
Key methods
static FileChannel open(Path, OpenOption...) | READ/WRITE/CREATE/APPEND options. |
int read(ByteBuffer dst, long position) | Positional read — no seek, thread-safe. |
MappedByteBuffer map(MapMode, long pos, long size) | Memory-map a region. |
long transferTo(long pos, long count, WritableByteChannel) | Zero-copy file → socket. |
FileLock lock() | Advisory cross-process file locking. |