Das war auch eine von hundert Kombinationen die ich probierte, und lieferte kein Erfolg. Dh. Compiler spuckt "...unsafe or unchecked operations" Meldung aus.
Das Programm würde auch so funktionieren, aber ich brauche es so, dass Compiler keine Fehlermeldungen ausgibt. Ich habs geschafft, indem ich den Inhalt von Vector speichere und nicht das ganze Vector. Es sieht jetzt so aus:
Code
[COLOR=#0115C8]void[/COLOR] saveTransactions [COLOR=#FF0000]()[/COLOR] [COLOR=#FF0000]{[/COLOR]
[COLOR=#0115C8]try[/COLOR] [COLOR=#FF0000]{[/COLOR]
[COLOR=#0115C8]ObjectOutputStream[/COLOR] objectOut [COLOR=#FF0000]=[/COLOR] [COLOR=#0115C8]new[/COLOR] [COLOR=#0115C8]ObjectOutputStream[/COLOR] [COLOR=#FF0000]([/COLOR][COLOR=#0115C8]new[/COLOR] [COLOR=#0115C8]FileOutputStream[/COLOR] [COLOR=#FF0000]([/COLOR][COLOR=#157A6C]"data"[/COLOR][COLOR=#FF0000]));[/COLOR]
[COLOR=#0115C8]int[/COLOR] anzahlVerbuchungen [COLOR=#FF0000]=[/COLOR] verbuchungen[COLOR=#FF0000].[/COLOR]size[COLOR=#FF0000]();[/COLOR]
objectOut[COLOR=#FF0000].[/COLOR]writeInt[COLOR=#FF0000]([/COLOR]anzahlVerbuchungen[COLOR=#FF0000]);[/COLOR]
[COLOR=#0115C8]for[/COLOR] [COLOR=#FF0000]([/COLOR][COLOR=#0115C8]int[/COLOR] i [COLOR=#FF0000]=[/COLOR] 0[COLOR=#FF0000];[/COLOR] i [COLOR=#FF0000]<[/COLOR] verbuchungen[COLOR=#FF0000].[/COLOR]size[COLOR=#FF0000]()[/COLOR] [COLOR=#FF0000];[/COLOR] i[COLOR=#FF0000]++)[/COLOR] [COLOR=#FF0000]{[/COLOR]
objectOut[COLOR=#FF0000].[/COLOR]writeObject[COLOR=#FF0000]([/COLOR]verbuchungen[COLOR=#FF0000].[/COLOR]get[COLOR=#FF0000]([/COLOR]i[COLOR=#FF0000]));[/COLOR]
[COLOR=#FF0000]}[/COLOR][COLOR=#808080][/COLOR]
objectOut[COLOR=#FF0000].[/COLOR]flush[COLOR=#FF0000]();[/COLOR]
objectOut[COLOR=#FF0000].[/COLOR]close[COLOR=#FF0000]();[/COLOR]
[COLOR=#FF0000]}[/COLOR]
[COLOR=#0115C8]catch[/COLOR] [COLOR=#FF0000]([/COLOR][COLOR=#0115C8]IOException[/COLOR] e[COLOR=#FF0000])[/COLOR] [COLOR=#FF0000]{[/COLOR][COLOR=#0115C8][/COLOR][COLOR=#FF0000][/COLOR][COLOR=#0115C8]System[/COLOR][COLOR=#FF0000].[/COLOR]exit[COLOR=#FF0000]([/COLOR]1[COLOR=#FF0000]);}[/COLOR]
[COLOR=#FF0000]}[/COLOR]
[COLOR=#0115C8]void[/COLOR] loadTransactions [COLOR=#FF0000]()[/COLOR] [COLOR=#FF0000]{[/COLOR]
[COLOR=#0115C8]try[/COLOR] [COLOR=#FF0000]{[/COLOR]
[COLOR=#0115C8]ObjectInputStream[/COLOR] objectIn [COLOR=#FF0000]=[/COLOR] [COLOR=#0115C8]new[/COLOR] [COLOR=#0115C8]ObjectInputStream[/COLOR] [COLOR=#FF0000]([/COLOR] [COLOR=#0115C8]new[/COLOR] [COLOR=#0115C8]FileInputStream[/COLOR][COLOR=#FF0000]([/COLOR][COLOR=#157A6C]"data"[/COLOR][COLOR=#FF0000]));[/COLOR]
[COLOR=#0115C8]int[/COLOR] anzahlVerbuchungen [COLOR=#FF0000]=[/COLOR] objectIn[COLOR=#FF0000].[/COLOR]readInt[COLOR=#FF0000]();[/COLOR]
[COLOR=#0115C8]for[/COLOR] [COLOR=#FF0000]([/COLOR][COLOR=#0115C8]int[/COLOR] i [COLOR=#FF0000]=[/COLOR] 0[COLOR=#FF0000];[/COLOR] i [COLOR=#FF0000]<[/COLOR] anzahlVerbuchungen[COLOR=#FF0000];[/COLOR] i[COLOR=#FF0000]++)[/COLOR] [COLOR=#FF0000]{[/COLOR]
verbuchungen[COLOR=#FF0000].[/COLOR]add [COLOR=#FF0000](([/COLOR]Zahlung[COLOR=#FF0000])[/COLOR] objectIn[COLOR=#FF0000].[/COLOR]readObject[COLOR=#FF0000]());[/COLOR]
[COLOR=#FF0000]}[/COLOR] [COLOR=#808080][/COLOR]
objectIn[COLOR=#FF0000].[/COLOR]close[COLOR=#FF0000]();[/COLOR]
[COLOR=#FF0000]}[/COLOR]
[COLOR=#0115C8]catch[/COLOR] [COLOR=#FF0000]([/COLOR][COLOR=#0115C8]IOException[/COLOR] e[COLOR=#FF0000])[/COLOR] [COLOR=#FF0000]{[/COLOR][COLOR=#0115C8][/COLOR][COLOR=#FF0000]}[/COLOR]
[COLOR=#0115C8]catch[/COLOR] [COLOR=#FF0000]([/COLOR][COLOR=#0115C8]ClassNotFoundException[/COLOR] e[COLOR=#FF0000])[/COLOR] [COLOR=#FF0000]{[/COLOR][COLOR=#0115C8][/COLOR][COLOR=#FF0000]}[/COLOR]
[COLOR=#FF0000]}
Alles anzeigen
[/COLOR]