Off by itself: RandomAccessFile

Bruce Eckel’s Thinking in Java Contents | Prev | Next

RandomAccessFile

Essentially,
a
RandomAccessFile
works like a
DataInputStream
pasted together with a
DataOutputStream
and
the methods
getFilePointer( )
to find out where you are in the file,
seek( )
to move to a new point in the file, and
length( )
to determine the maximum size of the file. In addition, the constructors
require a second argument (identical to
fopen( )
in
C) indicating whether you are just randomly reading (
“r”)
or reading and writing (
“rw”).
There’s no support for write-only files, which could suggest that
RandomAccessFile
might have worked well if it were inherited from
DataInputStream.

More by Author

Must Read