Main Page

Previous Next


In this chapter, we have discussed the various ways in which we can read basic types of data from a file. The important points we have discussed include:

  • You can read a file using a FileChannel object obtained from a FileInputStream object or from a RandomAccessFile object.

  • You can use a channel obtained from a RandomAccessFile object that was created with mode "rw" to both read and write the file.

  • Data that are read from a file using a channel is stored in one or more buffers of type ByteBuffer.

  • You can use view buffers to interpret the data read from a file as any basic type other than boolean.

  • A memory-mapped file enables you to access data in the file as though it were resident in memory.

  • Acquiring an exclusive lock on a file ensures that no other program can access the file while you hold the lock.

  • Acquiring a shared lock on a file ensures your program has access to the file in circumstances where other programs may be accessing the same file.

  • If you can't ride two horses at once, you shouldn't be in the circus.

Previous Next
JavaScript Editor Java Tutorials Free JavaScript Editor