我一直在嘗試將數組寫入文件。我知道如何將整數或字符串寫入文件,但是使數組混淆了我。我現在使用這個:如何將數組寫入文件Java
public static void write (String file, int[]x) throws IOException{
BufferedWriter outputWriter = null;
outputWriter = new BufferedWriter(new FileWriter(filename));
outputWriter.write("hi");// Here I know i cant just write x[0] or anything. Do i need
//to loop in order to write the array?
outputWriter.newLine();
outputWriter.flush();
outputWriter.close();
}
你在必須循環arry打印出每個元素 – NimChimpsky
Atleast google一次... – Parth
你想讓結果可以被人類或其他程序讀取嗎? –