如何将数组写入文件 Java
2022-09-03 08:45:50
我一直在尝试将数组写入文件。我知道如何将整数或字符串写入文件,但带来数组让我感到困惑。我现在正在使用它:
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();
}