forked from davidjava1991/java17CompleteCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample2.java
More file actions
28 lines (25 loc) · 798 Bytes
/
Copy pathExample2.java
File metadata and controls
28 lines (25 loc) · 798 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
package com.david.class134;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
public class Example2 {
public static void main(String[] args) {
try {
FileInputStream fis = new FileInputStream("./out/Student.txt");
ObjectInputStream ois = new ObjectInputStream(fis);
Student s = (Student)ois.readObject();
ois.close();
System.out.println("Student details");
System.out.println("id = "+s.id);
System.out.println("name = "+s.name);
System.out.println("branch = "+s.branch);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}