The Object stream is a mixture of primitive data type and object values. The ObjectInputStream class is a lot like DataInputStream class, except that it includes the powerful readObject() method. The ObjectInputStream class implements ObjectInput class which is sub interface of DataInput class.
Example:
/**
From objectInputStream.java
*/
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.Hashtable;
/**
*
* @author JavaHotSpot
*/
public class objectInputStream
{
public static void main(String args[])
{
try
{
FileInputStream fs = new FileInputStream("C:\\file2.txt");
ObjectInputStream obj = new ObjectInputStream(fs);
Hashtable ht = (Hashtable)obj.readObject();
System.out.append(ht.toString());
}
catch(Exception ex)
{
System.err.println(ex);
}
}
}
Output:
{Roll=12, Percentage=98.56, Name=ABC}
Related Articles:
FileInputStream
FileOutputStream
InputStreamReader
FileReader
FileWriter
BufferedInputStream
BufferedOutputStream
BufferedReader
BufferedWriter
DataInputStream
DataOutputStream
ObjectOutputStream
Related Articles:
FileInputStream
FileOutputStream
InputStreamReader
FileReader
FileWriter
BufferedInputStream
BufferedOutputStream
BufferedReader
BufferedWriter
DataInputStream
DataOutputStream
ObjectOutputStream