Advertisement
eerrtt

Untitled

Aug 30th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. public boolean save() {
  3. try {
  4. ObjectOutputStream oos = new ObjectOutputStream(
  5. new FileOutputStream(getDbFileName()));
  6. oos.writeObject(this);
  7. oos.close();
  8. return true;
  9. } catch (IOException ex) {
  10. ex.printStackTrace();
  11. return false;
  12. }
  13. }
  14.  
  15. public boolean load() {
  16. try {
  17. ObjectInputStream oos = new ObjectInputStream(new FileInputStream(
  18. getDbFileName()));
  19. Object obj = oos.readObject();
  20. BaseList<T> l = this.getClass().cast(obj);
  21. this.list = l.getList();
  22. this.nextId = l.nextId;
  23. oos.close();
  24. return true;
  25. } catch (IOException ex) {
  26. ex.printStackTrace();
  27. } catch (ClassNotFoundException e) {
  28. e.printStackTrace();
  29. }
  30. return false;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement