Im trying to read and write an object to a .ser file. This object is composede by and array of another objects, and an integer. Like this:
public class Ranking implements Serializable{
private static ArrayList<Acabada> partides = new ArrayList<Acabada>();
private int tipus_ordenacio;
}
When using serialitzation, the code seems to work. When I open the file generated there appears some unredeable stuff. But when writting (deserialization) I get this message:
tipus ordenacioo 1java.io.InvalidClassException: domain.Ranking; local class incompatible: stream classdesc serialVersionUID = 5620111485391998837, local class serialVersionUID = -3886134201979592842
This is the code I use to deserialize.
public void readFromFile() {
try {
FileInputStream fis = new FileInputStream("ranking.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
domain.Ranking ranking = (domain.Ranking) ois.readObject();
ois.close();
fis.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
What am I doing wrong? Thanks!