Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void saveToFile() throws IOException {
- File a = Engine.UploadsCache;
- BufferedWriter c = new BufferedWriter(new OutputStreamWriter(new DataOutputStream(new FileOutputStream(a))));
- for (Uploader b : Uploads.values()) {
- c.write("U:"+b.username+"\n");
- Set<String> e = b.URLs.keySet();
- for (String d : e) {
- String t = d;
- String u = b.URLs.get(d);
- c.write(t+"|URL|"+u+"\n");
- }
- }
- c.flush();
- c.close();
- }
- public void loadFromFile() throws IOException {
- File a = Engine.UploadsCache;
- if (!a.exists())
- throw new IOException("File does not exist.");
- BufferedReader b = new BufferedReader(new InputStreamReader(new DataInputStream(new FileInputStream(a))));
- String l = "";
- String user = "";
- Uploader c;
- while ((l = b.readLine()) != null) {
- if (l.startsWith("U:")) {
- user = l.replaceAll("U:", "");
- c = new Uploader(user);
- Uploads.put(user, c);
- }
- else {
- String[] d = l.split("\\|URL\\|");
- String t = d[0];
- String url = d[1];
- Uploads.get(user).addVideo(t, url);
- }
- }
- b.close();
- a.delete();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement