java - 在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");
}
解决方案
推荐阅读
- c# - 如何从字符串转换为系统日期时间格式?
- flutter - 如何在 Flutter 中将 Mobx 用于 List 对象?
- hl7-fhir - 匿名化 FHIR Json 的示例或插件
- html - Angular Material 表没有设计
- php - 如何重定向到仅显示从该 ID 插入数据库的数据的页面
- node.js - 让 webpack 忽略一个文件,只需要原始文件
- java - 下面的代码从一个文本参数读取并显示一个 mxn 矩阵,我想传递另一个文本参数并将其与第一个 1 进行比较
- azure - Azure 应用配置到强类型配置对象
- spring - spring boot 仅用于构建 rest api 吗?
- java - Spring & Hibernate:为什么获取 1 个惰性字段会触发加载所有其他惰性字段