O'Reilly logo

Java I/O, NIO and NIO.2 by Jeff Friesen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required