Je reçois une erreur de sortie quand je suis en train d'écrire le contenu de mon chaînée dans un fichier texteLinkedList écriture dans un fichier texte, mais la sortie est garbage
try {
FileOutputStream out = new FileOutputStream("ValidMovesMatrix.txt");
ObjectOutputStream oout = new ObjectOutputStream(out);
oout.writeObject("--+ This will show all the VALID moves A* algorithm has taken to come up with the solution +---");
oout.writeObject(" ");
for (int matrixIdx = 0; matrixIdx < matrixStack.size(); matrixIdx++) {
Object matrixShow = matrixStack.get(matrixIdx);
oout.writeObject(matrixShow);
}
oout.close();
} catch (Exception ex) {
System.out.println("Output error");
}
Il n'a pas imprimer le contenu de mon chaînée et le fichier texte de sortie contenait les déchets suivants:
¬í t _--+ This will show all the VALID moves A* algorithm has taken to come up with the solution +---t {sr java.io.NotSerializableException(Vx ç†5 xr java.io.ObjectStreamExceptiondÃäk9ûß xr java.io.IOExceptionl€sde%ð« xr java.lang.ExceptionÐý>;Ä xr java.lang.ThrowableÕÆ5'9w¸Ë L causet Ljava/lang/Throwable;L
detailMessaget Ljava/lang/String;[
stackTracet [Ljava/lang/StackTraceElement;L suppressedExceptionst Ljava/util/List;xpq ~ t MapStateur [Ljava.lang.StackTraceElement;F*<<ý"9 xp sr java.lang.StackTraceElementa Åš&6Ý… I
lineNumberL declaringClassq ~ L fileNameq ~ L
methodNameq ~ xpÿÿÿÿt java.io.ObjectOutputStreampt writeObject0sq ~
ÿÿÿÿq ~ pt writeObjectsq ~
bt
AlgoSolvert AlgoSolver.javat backtrackMovessq ~
'q ~ q ~ t searchsq ~
t
ProjectOnet ProjectOne.javat
acceptArgssq ~
q ~ q ~ t mainsr &java.util.Collections$UnmodifiableListü%1µìŽ L listq ~ xr ,java.util.Collections$UnmodifiableCollectionB €Ë^÷ L ct Ljava/util/Collection;xpsr java.util.ArrayListxÒ™Ça I sizexp w xq ~ $x
vous devriez rendre la classe sérialisable ou mettre du code vous-même pour la rendre imprimable .. elle vide pratiquement sa mémoire. –
comment je fais ça? – wazzza