-2
私は配列の迷路ボードを持っていますが、それをtxtファイルとして保存して印刷する方法を理解できないようです。配列をファイルとして出力しようとしていますか?
String [][] board = new String [][] {
{"#","#","#"," "," ","#" ,"#","#","#"},
{"#","#"," ","#"," ","#","#"," ","#"},
{"#"," "," "," ","#"," "," "," "," "},
{"#","#","#","#","#","#","#"," ","#"},
};
System.out.println(Arrays.toString(board));
File boardFile = new File("board.txt");
PrintWriter boardPW = new PrintWriter(boardFile);
boardPW.println(board);
Scanner scan = new Scanner(boardFile);
while(scan.hasNextLine()) {
System.out.println(scan.nextLine());
}
私はこれが完全に間違っているが、その価値があると感じる!笑
'Arrays.toString(ボード)は'多次元配列でうまく機能しません。代わりに 'Arrays.deepToString(board)'を試してください。 – Thomas
まだハハを印刷していない – A825
[FileWriterのJava txtファイルが空です](http://stackoverflow.com/questions/14060250/java-txt-file-from-filewriter-is-empty) – Tom