Почему тут, с BufferedInputStream / BufferedOutputStream вылетает EOFException?
File temp = File.createTempFile("my_file", "temp");
Solution solutionSave = new Solution(6);
Solution solutionLoad = new Solution(20);
try (ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(temp)));
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(temp)))) {
oos.writeObject(solutionSave);
solutionLoad = (Solution) ois.readObject();
} catch (IOException e) {
e.printStackTrace();
}
А тут, без BufferedInputStream / BufferedOutputStream не вылетает?
File temp = File.createTempFile("my_file", "temp");
Solution solutionSave = new Solution(6);
Solution solutionLoad = new Solution(20);
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(temp));
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(temp))) {
oos.writeObject(solutionSave);
solutionLoad = (Solution) ois.readObject();
} catch (IOException e) {
e.printStackTrace();
}