Advertisement
iPeer

Untitled

Aug 29th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public void saveToFile() throws IOException {
  2. File a = Engine.UploadsCache;
  3. BufferedWriter c = new BufferedWriter(new OutputStreamWriter(new DataOutputStream(new FileOutputStream(a))));
  4. for (Uploader b : Uploads.values()) {
  5. c.write("U:"+b.username+"\n");
  6. Set<String> e = b.URLs.keySet();
  7. for (String d : e) {
  8. String t = d;
  9. String u = b.URLs.get(d);
  10. c.write(t+"|URL|"+u+"\n");
  11. }
  12. }
  13. c.flush();
  14. c.close();
  15. }
  16.  
  17. public void loadFromFile() throws IOException {
  18. File a = Engine.UploadsCache;
  19. if (!a.exists())
  20. throw new IOException("File does not exist.");
  21. BufferedReader b = new BufferedReader(new InputStreamReader(new DataInputStream(new FileInputStream(a))));
  22. String l = "";
  23. String user = "";
  24. Uploader c;
  25. while ((l = b.readLine()) != null) {
  26. if (l.startsWith("U:")) {
  27. user = l.replaceAll("U:", "");
  28. c = new Uploader(user);
  29. Uploads.put(user, c);
  30. }
  31. else {
  32. String[] d = l.split("\\|URL\\|");
  33. String t = d[0];
  34. String url = d[1];
  35. Uploads.get(user).addVideo(t, url);
  36. }
  37.  
  38. }
  39. b.close();
  40. a.delete();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement