java - for Loop 2d 数组 BufferedWriter 未写入 txt
问题描述
我有这个代码:
try {
File file = new File("newbook.txt");
FileWriter fw = new FileWriter(file, true);
BufferedWriter out = new BufferedWriter(fw);
if (!file.exists()) {
file.createNewFile();
}
for (int r = 0; r < StuGrades.length; r++) {
for (int c = 0; c < StuGrades[0].length; c++) {
//out.write(StuGrades[r][c]);
out.write(" " + StuGrades[r][c]);
}
}
}catch(IOException e){
System.out.println("something's wrong");
}
它运行没有错误,但它没有在 txt 中写入任何内容。
解决方案
推荐阅读
- google-apis-explorer - 谷歌知识图怪行为的限制
- javascript - 如何使用位在 javascript 项目中创建打字稿组件?
- c - 在命令函数中保持状态
- arduino - 为“ESP8266WiFi.h”找到了多个库
- javascript - Shopify Buy Button via JS — 购物车显示错误的货币
- javascript - 尝试使用表单添加新帖子时出现错误
- asp.net - 为 asp.net 应用程序部署指定 DeployIisAppPath
- c# - 将事件监听器绑定到来自其他页面视图 (MVVM) 的事件
- docker - Docker 作为具有现有 ssh 密钥的 SSH 代理
- excel-formula - 使用 Excel 公式计算复合增长的平均百分比