-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAccountDB.java
More file actions
43 lines (35 loc) · 1.14 KB
/
AccountDB.java
File metadata and controls
43 lines (35 loc) · 1.14 KB
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
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
public class AccountDB extends ObjectOutputStream{
ArrayList<Account> accounts;
public AccountDB(OutputStream out) throws IOException {
super(out);
}
protected void writeStreamHeader() throws IOException {
reset();
}
public void Writeaccount(Account a) throws IOException {
FileOutputStream fout = new FileOutputStream("C:\\Users\\amr\\eclipse-workspace\\Masroka\\AccocuntDB.ser");
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(a);
oos.close();
}
public void readaccount() throws IOException {
ObjectOutputStream oos = null;
FileOutputStream fout = null;
try{
fout = new FileOutputStream("C:\\Users\\amr\\eclipse-workspace\\Masroka\\AccocuntDB.ser", true);
oos = new ObjectOutputStream(fout);
oos.writeObject(accounts);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if(oos != null){
oos.close();
}
}
}
}