This section illustrates you how to read and write from/to a serialized file through the hash table in Java. This section provides an example with the complete code of the program. Following program has the facility if the specified serialized file does not exist the the program creates the serialized file otherwise. This program first write to the specified serialized file if it exists otherwise read all contents by de-serializing the file.
Code Description:
FileOutputStream fileOut = new FileOutputStream("HTExample.ser"):
Above code creates an object "fileOut" of the FileOutputStream
with it's constructor which takes a file name which contains ".ser"
extension that determines for the serialized file either which has to be created
or written with the specified value in a hash table in the program.
Here is the code of the program:
import java.util.*;
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Writing and reading from/to a serialized file through Hash Table in Java
Post your Comment