Tag: bufferedwriter

如何将数组写入文件Java

我一直在试图写一个数组到一个文件。 我知道如何写整数或string到一个文件,但带来一个数组混淆我。 我现在正在使用这个: 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(); }