19.3 Random Access Files
Files can be read and modified in two different ways: first, via a data stream that processes bytes as in a media stream and, second, via random access. While the data stream enforces a strict sequence, random access doesn’t care because it can jump back and forth arbitrarily within a file and maintains a file pointer that you can set. Since we’re dealing with files, the whole thing is then called a random access file, and the class that provides random access is java.io.RandomAccessFile .
19.3.1 Opening a RandomAccessFile for Reading and Writing
The class declares two constructors that use a file name or File object to create a RandomAccessFile object. In the constructor, the second parameter specifies a string ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access