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.
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:
Liked it! Share this Tutorial