Uh oh!
There was an error while loading. Please reload this page.
forked from gihanjayatilaka/Motify
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayFileHandling.java
More file actions
Latest commit
28 lines (26 loc) · 1.1 KB
/
Copy pathArrayFileHandling.java
File metadata and controls
28 lines (26 loc) · 1.1 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
//Testing Git
importjava.io.*;
importjava.util.ArrayList;
publicclassArrayFileHandling {
publicstaticvoidsaveArrayCustomName(ArrayList<Reminder> arrayToSave,StringfileName) throwsException{
FileOutputStreamfos=newFileOutputStream(fileName);
ObjectOutputStreamoos=newObjectOutputStream(fos);
oos.writeInt(arrayToSave.size());
for(intx=0;x<arrayToSave.size();x++) oos.writeObject(arrayToSave.get(x));
}
publicstaticArrayList<Reminder> readArrayCustomName(StringfileName) throwsException{
FileInputStreamfis=newFileInputStream(fileName);
ObjectInputStreamois=newObjectInputStream(fis);
intnoOfReminders=ois.readInt();
ArrayList<Reminder> arrayRead=newArrayList<Reminder>();
for(intx=0;x<noOfReminders;x++) arrayRead.add((Reminder)ois.readObject());
arrayRead=ArrayHandling.sortReminders(arrayRead);
returnarrayRead;
}
publicstaticvoidsaveArray(ArrayList<Reminder> arrayToSave) throwsException{
saveArrayCustomName(arrayToSave,"database.dat");
}
publicstaticArrayList<Reminder> readArray() throwsException{
returnreadArrayCustomName("database.dat");
}
}