Until now I thought we had to re-declare our fields one by one in the readObject method's, like this :
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
fileName = (String) in.readObject();
in.defaultReadObject();
stream = new FileOutputStream(fileName,true);
}
And thus (in this exercise), use it to re-declare the stream field, but the solution was this one :
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
stream = new FileOutputStream(fileName,true);
}
Does that mean that by using in.defaultReadObject() method's we obtain a complete reset of our class and can retrieve the desired info, here the filename?