Serialisation refusée si objet non-instancié?
Bonjour,
Peut-être sauriez-vous m'apporter des précisions sur ce problème qui semble avoir une cause simple, mais qui me laisse perplexe: je dois obligatoirement instancier mon objet dans ma classe IndexExporter. En effet, si je le passe en argument à ma fonction, j'obtiens une exception.
Puisque le code est court et parlant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
public class IndexExporter {
public static void export(IndexList indexList) throws IOException {
// Ca marche si j'instancie la classe directement ici:
// indexList = new IndexList();
// Sinon, j'ai une NotSerializableException.
FileOutputStream f = new FileOutputStream("./.index");
ObjectOutputStream o = new ObjectOutputStream(f);
o.writeObject(indexList);
o.close();
}
} |
Dans l'attente d'une réponse :)