Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public void saveOnFile() {
  2. try {
  3. ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("object.txt"));
  4. output.writeObject(mediaList);
  5. output.close();
  6. } catch(Exception ex) {
  7. ex.printStackTrace();
  8. }
  9. }
  10.  
  11. public void readFromFile() {
  12. try {
  13. ObjectInputStream inStream = new ObjectInputStream(new FileInputStream("object.txt"));
  14. this.mediaList.add( (Media) inStream.readObject());
  15. inStream.close();
  16. } catch(Exception ex) {
  17. ex.printStackTrace();
  18. }
  19. }
  20.  
  21. java.lang.ClassCastException: java.util.ArrayList cannot be cast to project.Media
  22. at project.MediaHandler.readFromFile(MediaHandler.java:66)
  23. at project.Window.<init>(Window.java:73)
  24. at project.Window.main(Window.java:199)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement