Bonjour à tous,

Je voudrais sérialiser puis désérialiser une Hashtable mais je bataille avec un "unchecked or unsafe operations" .
J'ai lu bcp de tutos et de messages (génériques, sérialisation, cast )mais je ne vois tjs pas : Hashtable paramétrée, Serializable implantée partout...

voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
...
 Compte testCompte= new CompteCourant("DUSCHMOLL", "Gérard");
 FileOutputStream fos=null;
 ObjectOutputStream myOut=null;
 
 try{     fos= new FileOutputStream("test2.dat");
            myOut= new ObjectOutputStream(fos);
            myOut.writeObject(testCompte);
            myOut.flush();
 }
 catch(FileNotFoundException fnfe){System.out.println("Le fichier mentionné  n'a pu être trouvé !");}  
 catch(IOException e1){System.out.println("Une erreur d'entrée sortie s'est produite !!");}
 
 finally{ if(myOut!=null){myOut.close();}
}   
 
 
 FileInputStream fis=null;
  ObjectInputStream myIn=null;
     try{
               fis=new FileInputStream("test2.dat");
               myIn= new ObjectInputStream(fis);
               Hashtable<String, Compte> sortie= new Hashtable<String, Compte>();
               //c'est ce cast-là qui est refusé :
               sortie = (Hashtable<String, Compte>)myIn.readObject();
               System.out.println(sortie.keySet()); 
   }
   catch(FileNotFoundException fnfe){System.out.println("Le fichier mentionné n'a pu être trouvé !");}  
   catch(ClassNotFoundException cnfe){System.out.println("classe non  trouvée !!");}
   catch(IOException e1){System.out.println("Une erreur d'entrée sortie s'est produite !!");}
 
 finally{ if(myIn!=null){myIn.close();}
}
pour info, la classe abstraite "Compte" a entre autre comme fille la classe "CompteCourant".

Tous mes remerciements à ceux qui pourront me donner qq indices !