0

I actually have an object called Ranking which consists in ArrayList of Objects, and an Integer. Like this:

private static ArrayList<Acabada> partides = new ArrayList<Acabada>();
private int tipus_ordenacio;

When I try to deserialize from a .ser file, I don't get all the attributes, just the integer. When I try to make .size() from the array I get 0. It seems that it deserialize the integer correctly but not the Array of Objects. What should I do? Below is my deserialization code.

public domain.Ranking llegirRanking() {

        Ranking ranking;
        try {
            FileInputStream fileIn = new FileInputStream("ranking.ser");
            ObjectInputStream in = new ObjectInputStream(fileIn);
            ranking = (Ranking) in.readObject();
            System.out.println("tipus ordenacio :"+ranking.getTipus_ordenacio());
            System.out.println("tamany :"+ranking.getTamany());
            in.close();
            fileIn.close();


        }
Kara
  • 6,115
  • 16
  • 50
  • 57
sergi martinez
  • 165
  • 1
  • 8

1 Answers1

0

Static fields are not serialized. See the Javadoc and the Object Serialization Specification.

user207421
  • 305,947
  • 44
  • 307
  • 483