-
Notifications
You must be signed in to change notification settings - Fork 0
/
WriteToFileDATAB.java
52 lines (39 loc) · 1.35 KB
/
WriteToFileDATAB.java
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
46
47
48
49
50
51
52
package com.wallpapernote.plutopix.wallpaperorganizer;
import android.content.Context;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
public class WriteToFileDATAB {
private File mFile;
public WriteToFileDATAB(File file){
this.mFile = file;
}
public void saveArrayList(ArrayList<Model> arrayList) {
try {
FileOutputStream fileOutputStream = new FileOutputStream(mFile);
ObjectOutputStream out = new ObjectOutputStream(fileOutputStream);
out.writeObject(arrayList);
out.close();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public ArrayList<Model> getSavedArrayList(File text) {
ArrayList<Model> savedArrayList = null;
try {
FileInputStream inputStream = new FileInputStream(text);
ObjectInputStream in = new ObjectInputStream(inputStream);
savedArrayList = (ArrayList<Model>) in.readObject();
in.close();
inputStream.close();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return savedArrayList;
}
}