February 2014
Beginner
1248 pages
62h 25m
English
The preceding section showed how to create a file for sequential access using object serialization. In this section, we discuss how to read serialized data sequentially from a file.
The program in Fig. 15.11 reads records from a file created by the program in Section 15.5.1 and displays the contents. The program opens the file for input by calling Files static method newInputStream, which receives a Path specifying the file to open and, if the file exists, returns an InputStream that can be used to read from the file. In Fig. 15.10, we wrote objects to the file, using an ObjectOutputStream object. Data must be read from the file in the same format in which it was written. Therefore, ...
Read now
Unlock full access