Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. package bookclub1;
  2.  
  3. import java.io.FileInputStream;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;
  7. import java.io.ObjectInputStream;
  8. import java.io.ObjectOutputStream;
  9. import java.util.LinkedList;
  10.  
  11. public class MemberList {
  12.  
  13. public static void SaveMember(LinkedList<member> books) throws IOException {
  14.  
  15. ObjectOutputStream B;
  16. try {
  17. B = new ObjectOutputStream(new FileOutputStream("src/bookclub1/MemberList.txt"));
  18. B.writeObject(books);
  19. B.close();
  20.  
  21. } catch (FileNotFoundException e) {
  22.  
  23. e.printStackTrace();
  24. } catch (IOException e) {
  25.  
  26. e.printStackTrace();
  27. }
  28.  
  29. }
  30.  
  31. public static LinkedList<member> readBooks(LinkedList<member> readBooks) throws ClassNotFoundException {
  32.  
  33. try {
  34. ObjectInputStream bookstock = new ObjectInputStream(new FileInputStream("src/bookclub1/Memberlist.txt"));
  35. readBooks = (LinkedList<member>) bookstock.readObject();
  36. } catch (FileNotFoundException e) {
  37.  
  38. e.printStackTrace();
  39. } catch (IOException e) {
  40.  
  41. e.printStackTrace();
  42. }
  43. return readBooks;
  44.  
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement