首页 > 解决方案 > 在Java的循环中使用数组写入文件

问题描述

我正在学习 Java(15 岁),目前我真的被困在部分代码上。我需要知道如何写入循环中的数组中的文件,但我无法将其写入。我需要它,以便用户使用扫描仪输入自己的答案。我需要在不使用输出流的情况下做到这一点。

public static void modStudents() {
    String[][] students = new String[12][4];
    String output = "";
   BufferedWriter writefile = null;

    try {
        for (int i = 0; i < 12; i++) {
             writefile = new BufferedWriter(new FileWriter("StudentNames.txt"));
            String content[] = output.split(",");
            for (int j = 0; j < 3; j++) {
                students[i][j] = content[j];
} catch (Exception e) {
        System.out.println("Somethings gone wrong");

    }

标签: javaarrayswriting

解决方案


推荐阅读