-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathser_ex.java
More file actions
45 lines (34 loc) · 965 Bytes
/
ser_ex.java
File metadata and controls
45 lines (34 loc) · 965 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
34
35
36
37
38
39
40
41
42
43
44
45
package java_example;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
class emp implements Serializable {
int eid;
String ename;
emp(int eid , String ename){
this.eid=eid;
this.ename= ename;
}
}
class ser_ex {
public static void main (String args[]){
try{
/*emp obj = new emp(1,"gowtham");
FileOutputStream fout = new FileOutputStream("E:\\Users\\stream.txt");
ObjectOutputStream a = new ObjectOutputStream(fout);
a.writeObject(obj);
a.flush();
a.close();
System.out.println("success");*/
ObjectInputStream b = new ObjectInputStream(new FileInputStream("E:\\Users\\stream.txt"));
emp d =(emp)b.readObject();
System.out.println(d.eid+","+d.ename);
b.close();
}
catch (Exception e){
System.out.println(e);
}
}
}