Java Reference
In-Depth Information
{
SerEmployee(String name) { super(name); }
}
class SerializationDemo
{
public static void main(String[] args)
{
try (ObjectOutputStream oos =
new
ObjectOutputStream(new
FileOut-
putStream("employee.dat")))
{
SerEmployee se = new SerEmployee("John Doe");
System.out.println(se);
oos.writeObject(se);
System.out.println("se object written to file");
}
catch (Exception e)
{
e.printStackTrace();
}
try (ObjectInputStream ois =
new
ObjectInputStream(new
FileIn-
putStream("employee.dat")))
{
Object o = ois.readObject();
System.out.println("se object read from byte ar-
ray");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Search WWH ::




Custom Search