Advertisement
PasteManArs

Untitled

May 11th, 2023
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1.     public static void serializeHouse(House house, String filename)
  2.     {
  3.         try(ObjectOutput out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(filename))))
  4.         {
  5.             out.writeObject(house);
  6.         }
  7.         catch (IOException e)
  8.         {
  9.             System.out.println("Писюн " + e.getMessage());
  10.         }
  11.     }
  12.     public static House deserializeHouse(String filename) throws IOException, ClassNotFoundException, ClassCastException {
  13.         try (ObjectInput in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(filename)))) {
  14.             return (House) in.readObject();
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement