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 35 36 37 38 39 40 41 42 43 44 45
|
public class Question implements Serializable{
public static void main(String[] args) {
MaFenQuestion C1;
MaFenQuestion C2;
QuestionBinaire QBS;
QBS = new QuestionBinaire ("test");
C1 = new MaFenQuestion("Question de sondage",200,200, QBS, "pour", "contre");
C2 = new MaFenQuestion("Question de sondage",200,200, QBS, "pour", "contre");
LinkedList listeClient = new LinkedList();
listeClient.add(C1);
listeClient.add(C2);
try{
FileOutputStream sortie = new FileOutputStream("test.sond");
ObjectOutputStream p = new ObjectOutputStream(sortie);
p.writeObject(listeClient);
p.flush();
sortie.close();
}catch(IOException ioe){
System.out.println("erreur dans la sérialisation : "+ ioe);
}
try {
FileInputStream f = new FileInputStream("test.sond");
f.read();
} catch (FileNotFoundException e) {
// . . .
} catch (IOException e) {
// . . .
}
}} |
Partager