Posted by : Rhyf Ahmad Saturday, May 23, 2015

In this chapter you investigate how you read files containing basic types of data. You explore how to read files sequentially or at random and how you can open a file for both read and write operations.
The process for reading a fi le parallels that of writing a file so if you are comfortable with writing files, this chapter is going to be easy. You have three ways for reading files, all provided by static methods in the java.nio.file.Files class:
The newInputStream() method returns an InputStream object, which you can use to read a binary file.
The newBufferedReader() method returns a BufferedReader object, which you can use to read a file containing character data.
The newByteChannel() method that you used in the Chapter 10 returns a reference to a FileChannel object as type SeekableByteChannel, which you can use to read a file when the READ open option is in effect. You can read binary or character data from the file.
I cover the first two briefly because they are quite simple and then concentrate on the third option, which uses a FileChannel object.


File Read Operations

  1. Reading a File Using an Input Stream
  2. Reading a File Using a Buffered Reader
Reading a File Using a Channel

  1. Reading a Text File
  2. Getting Data from the Buffer
  3. Reading Binary Data
  4. Reading Mixed Data
  5. Compacting a Buffer
Copying Files
Random Access to a File
Memory-Mapped Files

  1. Locking a File
  2. Locking Part of a File
  3. Practical File Locking Considerations

Ebook Preview

If the link above doesn't work, try the link below

Leave a Reply

You can leave a comment to request any article(s), software(s), ebook(s) or report the dead link.
Then I will reply as soon as I can :)

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Recent Post

Recent Posts Widget

- Copyright © Madriva -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -