Bonjour tout le monde

J'aurais besoin de votre aide pour la serialisation et deserialisation d'objet en java.

Voici le travail que j'ai déjà fais :

Serialisation :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
public static void serialStylo (Stylo sty)
  {
	  try
	  {
		  ObjectOutputStream objFic;
		  objFic = new ObjectOutputStream(new FileOutputStream("stylo.ser", true));
		  objFic.writeObject(sty);
		  objFic.flush();
		  objFic.close();
	  }
	  catch(Exception e){System.err.println(e); System.exit(1);}
  }
Deserialisation :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
public static void serialStylo (Stylo sty)
{
	  try
	  {
	  	  FileInputStream fic = new FileInputStream("stylo.ser");
		  ObjectInputStream objFic = new ObjectInputStream(fic);
		  Stylo stylo = (Stylo) objFic.readObject();
		  System.out.println(stylo.getRef()+" "+stylo.getMarque()+" "+stylo.getPrix()+" "+stylo.getCouleur());
		  objFic.close();
	  }
	  catch(Exception e){System.err.println(e); System.exit(1);}
}
J'ai fais différents tests avec ces quelques methodes et j'ai remarqué que quand je déserialisais mon Stylo, qui est composé de 4 attributs (String, String, double, String)

il m'affiche :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
null null 0.0 rouge
Alors que les 3 premiers attributs sont renseigner correctement.

PLEASE HELP ME
Merci...