Hello everyone, I'm having a really strange problem and I can't figure out why.
public void readEmpregados(ArrayList <Classe_Pessoa> list) throws IOException, ClassNotFoundException {
FileInputStream file;
try {
file=new FileInputStream(this.empregados);
}
catch (FileNotFoundException e) {
this.empregados.createNewFile();
return;
}
System.out.println("I'm here");
try {
ObjectInputStream out=new ObjectInputStream(file);
Object prototype=out.readObject();
if (prototype instanceof ArrayList) {
list=(ArrayList <Classe_Pessoa>)prototype; /*Faz cast para list*/
}
}
catch (Exception e) {
System.out.println("Something is wrong");
}
System.out.println("############Here's what I sent"+list);
This is supposed to read an ArrayList of "Classe_Pessoas" from a file and save it on the variable "list". It is working as intended. But for some reason, any changes I make to "list" are discarded as soon as this method returns.
If it's any help, list is private.