Chapter 3
RandomAccessFile
Files can be created and/or opened for random access in which a mixture of write and read operations at various locations can occur until the file is closed. Java supports this random access by providing a java.io.RandomAccessFile class. I explore RandomAccessFile in this chapter.
Exploring RandomAccessFile
RandomAccessFile declares the following constructors:
- RandomAccessFile(File file, String mode): Create and open a new file when it doesn’t exist or open an existing file. The file is identified by file’s abstract path and is created and/or opened according to mode.
- RandomAccessFile(String path, String mode): Create and open a new file when it doesn’t exist or open an existing file. The file is identified by
Get Java I/O, NIO and NIO.2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.