-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIO.java
More file actions
38 lines (33 loc) · 993 Bytes
/
IO.java
File metadata and controls
38 lines (33 loc) · 993 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
package tuan.IO;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class IO implements java.io.Serializable{
public void WriteFile(Object Obj, String fileName) throws Exception{
// try {
FileOutputStream f = new FileOutputStream(fileName);
ObjectOutputStream output = new ObjectOutputStream(f);
output.writeObject(Obj);
output.close();
f.close();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
}
public Object ReadFile(String fileName) throws Exception{
Object SP = null;
// try {
FileInputStream f = new FileInputStream(fileName);
ObjectInputStream input = new ObjectInputStream(f);
SP = input.readObject();
input.close();
f.close();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// }
return SP;
}
}