-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDeserializableTest.java
More file actions
33 lines (29 loc) · 989 Bytes
/
DeserializableTest.java
File metadata and controls
33 lines (29 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
public class DeserializableTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Country india = null;
try
{
FileInputStream fileIn =new FileInputStream("country.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
india = (Country) in.readObject();
in.close();
fileIn.close();
}catch(IOException i)
{
i.printStackTrace();
return;
}catch(ClassNotFoundException c)
{
System.out.println("Country class not found");
c.printStackTrace();
return;
}
System.out.println("Deserialized Country...");
System.out.println("Country Name : " + india.getName());
System.out.println("Population : " + india.getPopulation());
}
}