A RandomAccessRecordFile object represents a file opened for random access. The file is opened implicitly when the object is generated (see section "Opening and closing a file" below).
The RandomAccessRecordFile class offers methods for reading and writing records and for shortening and extending this file. There are also methods for positioning and for closing the file.
The file that is to be opened must already exist in the underlying file system. The createNewFile() method of the RecordFile class must be used to generate a file.
For a file that has been opened for random access a current file position is always defined at which the next read or write operation takes place. The current file position is defined by the number of the record in accordance with the sequence of records in this file, the records being numbered starting with zero. The current file position after the file is opened is the start of file.
When a file is opened for random access, the specific access direction can be restricted and deletion of the contents of an existing file can be requested.
The following open modes are permitted with this class:
INPUT
After the file has been opened only read operations are permitted.OUTIN
After the file has been opened both write and read operations are permitted. The entire file contents are deleted when the file is opened.INOUT
After the file has been opened both read and write operations are permitted. The file contents remain unchanged when the file is opened.
After the file has been closed the RandomAccessRecordFile object should no longer be used.