forked from gihanjayatilaka/Motify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRSSFileHandling.java
More file actions
21 lines (20 loc) · 874 Bytes
/
RSSFileHandling.java
File metadata and controls
21 lines (20 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
public class RSSFileHandling {
static public void saveRSSData(ArrayList<NotificationUpdate> arrayToSave) throws Exception{
FileOutputStream fos=new FileOutputStream("RSSdata.dat");
ObjectOutputStream oos=new ObjectOutputStream(fos);
oos.writeInt(arrayToSave.size());
for(int x=0;x<arrayToSave.size();x++) oos.writeObject(arrayToSave.get(x));
}
static public ArrayList<NotificationUpdate> readRSSData() throws Exception{
FileInputStream fis=new FileInputStream("RSSdata.dat");
ObjectInputStream ois=new ObjectInputStream(fis);
int N=ois.readInt();
ArrayList<NotificationUpdate> arrayBeingRead=new ArrayList<NotificationUpdate>();
for(int x=0;x<N;x++) arrayBeingRead.add((NotificationUpdate) ois.readObject());
Collections.sort(arrayBeingRead);
return arrayBeingRead;
}
}