File access methods
The information stored in the file needs to be accessed and read into the computer memory. There are different methods available to do it. Some of them are:
- This is the most common method.
- Here the information present in the file is accessed in a sequential fashion, one record after the other.
- It is a very common approach which is used by editors and compilers usually.
- The Read and Write operations form the major part of the operations done on a file.
- A read operation reads the next portion of the file and automatically advances the file pointer, which tracks the I/O location.
- A write operation appends to the end of the file and advances to the end of the newly written material.
- This type of access method provides a speedy access to the file. It provides immediate access to large amount of information.
- Here a file is made up of logical records that allow programs to read and write.
- It allows the programs to read and write the records in a rapid manner in no particular (or pre-defined) order.
- It is based on the disk-model of a file, as a disk allows random access to any block.
- For direct access, we can view the file as a numbered sequence of blocks or records.
- This method is usually used in databases.
- This method is built on top of Direct access method.
- Here an index contains the pointers to various blocks of the file.
- So, to find a record inside a file, we firstly search the index and later use the pointer obtained to access the file directly and find the record we have been searching for.