Close
Register
Close Window

F17 OpenDSA entire modules

Chapter 14 File Processing

Show Source |    | About   «  14.4. Buffer Pools   ::   Contents   ::   14.6. External Sorting  »

14.5. The Programmer's View of Files

The programmer's logical view of a random access file is a single array of bytes. Interaction with a file can be viewed as a communications channel for issuing one of three instructions: read bytes from the current position in the file, write bytes to the current position in the file, and move the current position within the file. You do not normally see how the bytes are stored on the disk in sectors, clusters, and so forth. The mapping from logical to physical addresses is done by the file system, and sector-level buffering is done automatically by the disk controller.

When processing records in a disk file, the order of access can have a great effect on I/O time. A random access procedure processes records in an order independent of their logical order within the file. Sequential access processes records in order of their logical appearance within the file. Sequential processing requires less seek time if the physical layout of the disk file matches its logical layout, as would be expected if the file were created on a disk with a high percentage of free space.

Java provides several mechanisms for manipulating disk files. One of the most commonly used is the RandomAccessFile class. The following methods can be used to manipulate information in the file.

Note that the spirit if this ADT is similar to message passing version of the ADT for buffer pools.

   «  14.4. Buffer Pools   ::   Contents   ::   14.6. External Sorting  »

nsf
Close Window