Title: Key Concept - Random access within a file
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: Learning Modules

Random access enables a file to read from or written to at a particular location within the file.

The following methods, from class java.nio.channels.FileChannel and interface SeekableByteChannel, enable random file access:

- position – returns and sets the channel's current position.
- read – reads bytes from the channel to the buffer.
- write – writes bytes from the buffer to the channel.
- truncate – truncates the file connected to the channel.

For additional study, view resources under:

- Level 2 Study Materials: Unit 2
- Level 2 Study Materials: Unit 3