What are random access files?
Category:
technology and computing
data storage and warehousing
Random-access file is a term used to describe a file or set of files that are accessed directly instead of requiring that other files be read first. Computer hard drives access files directly, where tape drives commonly access files sequentially. Direct access, Hardware terms, Sequential file.
Correspondingly, what is random access file in C?
Random access means you can move to any part of a file and read or write data from it without having to read through the entire file. Years ago, data was stored on large reels of computer tape. The only way to get to a point on the tape was by reading all the way through the tape.
Secondly, how do I use a random access file?
Java RandomAccessFile Example
- getFilePointer() to get the current position of the pointer.
- seek(int ) to set the position of the pointer.
- read(byte[] b) to reads up to b. length bytes of data from the file into an array of bytes.
- write(byte[] b) to write b. length bytes from the specified byte array to the file, starting at the current file pointer.
Records are numbered sequentially, starting with record number 1. All records have the length specified by the RECL option in the OPEN statement. Data in direct files is accessed by specifying the record you want within the file. If you need random access I/O, use direct-access files.