IDEA写了几行java,想把一个二维数组放入txt中,数组大致如下:
结果最后打开txt,显示如下:
放上代码大家再看一下:
```java
Path path = Paths.get(fileName);
try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
for (int i = 0; i < 1875; i++) {
for (int j = 0; j < 1875; j++) {
writer.write(array[i][j]);
writer.write(" ");
}
// System.out.println("写入第"+i);
writer.newLine();
}
}
```