Advertisement
Camer047

Untitled

Jan 4th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public void writetodisk()
  2. {
  3. try
  4. {
  5. FileOutputStream fileOut =
  6. new FileOutputStream("plugins/tokendata.txt");
  7. ObjectOutputStream out = new ObjectOutputStream(fileOut);
  8. out.writeObject(map);
  9. out.close();
  10. fileOut.close();
  11. System.out.printf("Serialized data is saved in data.txt");
  12. }catch(IOException i)
  13. {
  14. i.printStackTrace();
  15. }
  16. }
  17.  
  18. @SuppressWarnings("unchecked")
  19. public void readfromdisk () {
  20. try
  21. {
  22. FileInputStream fileIn =
  23. new FileInputStream("plugins/tokendata.txt");
  24. ObjectInputStream in = new ObjectInputStream(fileIn);
  25. map = (HashMap<UUID, Integer>) in.readObject();
  26. in.close();
  27. fileIn.close();
  28. System.out.printf("Serialized data is saved in data.txt");
  29. }catch(IOException i)
  30. {
  31. i.printStackTrace();
  32. }
  33. catch(ClassNotFoundException c)
  34. {
  35. System.out.println("Class not found");
  36. c.printStackTrace();
  37. }
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement