1
它将在控制台中打印数组,因此我知道循环正在工作,但PrintWriter不会在文件中打印任何内容。PrintWriter将不会在我的循环中工作,但我的循环正在工作
public static void writePuzzle(char[][] puzzle, String file){
try{
PrintWriter pr = new PrintWriter(new FileWriter ((file)));
for(int i= 0 ; i<puzzle.length; i++){
for(int j= 0 ; j<puzzle.length; j++){
pr.print(puzzle[i][j]);
System.out.print(puzzle[i][j]);
}
pr.println();
System.out.println("");
}
} catch (IOException e) {
e.printStackTrace();
}
}
谢谢!但我还没有明白,有没有其他方法? – Ronbonbeno 2014-10-10 02:11:08
你的意思是你没有学到什么?它在官方文档中。 – 2014-10-10 02:21:59