P
paidopoieo
Gast
Hallo
Ich hab hier ein Codestueck, das mir saemtliche Permutationen ausgibt, auf die Konsole funktioniert es, jedoch das Schreiben in ein File
nicht. Es legt mir zwar das File an, jedoch wird mir nur die letzte Permutation reingeschrieben....
vielen Dank im Voraus...
lg
[/code]
Ich hab hier ein Codestueck, das mir saemtliche Permutationen ausgibt, auf die Konsole funktioniert es, jedoch das Schreiben in ein File
nicht. Es legt mir zwar das File an, jedoch wird mir nur die letzte Permutation reingeschrieben....
Code:
private static void permRek (char[] auswahl, char[] buf, int index) throws IOException {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("MyFile.txt")));
if (index == buf.length) {
System.out.println(buf);
}
else {
for (int i=0; i < auswahl.length; i++) {
buf[index] = auswahl[i];
permRek(auswahl, buf, index+1);
}
}
out.write(buf);
out.newLine();
out.close();
}
public static void permutation (String auswahl, int anzahl) throws IOException {
permRek(auswahl.toCharArray(), new char[anzahl], 0);
}
vielen Dank im Voraus...
lg
[/code]