Good afternoon.
I am a beginner in Java and I am working right now with the storage of objects in serialized files using the methods of class Object
( ObjectInput
and ObjectOutput
).
When I save the object I do not have problems, but when I try to add it to the program, I do not have much idea of how to do it, in terms of declaration and initialization of that same object extracted from the serialized file.
This is my code to load the object
private File player= new File("./data/players.ser");
public void loadPlayer(){
try {
ObjectInput input = new ObjectInputStream(new FileInputStream(player));
//Procedimiento para realizar el input.readObject(); ???
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}