Alx09

sdda

Nov 9th, 2021
1,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. static void seralizare(Object o, String fis) {
  2.         try {
  3.             FileOutputStream f = new FileOutputStream(fis);
  4.             ObjectOutputStream oos = new ObjectOutputStream(f);
  5.             oos.writeObject(o);
  6.             oos.close();
  7.             f.close();
  8.         } catch (IOException e) {
  9.             e.printStackTrace();
  10.         }
  11.     System.out.println("Seralizarea a avut succes");
  12.     }
  13.  
  14.     static Object deSeralizare(String fis) {
  15.         try {
  16.             FileInputStream f = new FileInputStream(fis);
  17.             ObjectInputStream ois = new ObjectInputStream(f);
  18.             Object o = ois.readObject();
  19.             ois.close();
  20.             f.close();
  21.  
  22.             return o;
  23.         } catch (IOException | ClassNotFoundException e) {
  24.             e.printStackTrace();
  25.         }
  26.         return null;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment