Guest User

Untitled

a guest
Jun 22nd, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. //моя функция сериализации, в цикле из main передаётся производный от абстрактного класса Composition объект
  2. public void writeToFile(Composition c) throws IOException{
  3.         ObjectOutputStream objectOutputStream=new ObjectOutputStream(new FileOutputStream("Com.bin",true));
  4.         objectOutputStream.writeObject(c);
  5.  
  6.     }
  7. //функция десериализации, не работает
  8.     public Composition[] readFile() throws IOException, ClassNotFoundException{
  9.         Composition[] vid;
  10.         try (ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("Com.bin"))) {
  11.             vid = (Composition[]) objectInputStream.readObject();
  12.         }
  13.         return vid;
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment