java - 带矩阵的文件 IO
问题描述
我正在尝试接收输入 txt 文件并将相同的文件输出到不同的 txt 文件。但是,我需要将输入文件上的每个矩阵输出到一个二维数组中,并且在每个矩阵之后我想写“行列式:”。我的代码没有像现在这样向输出文件写入任何内容。为什么它不起作用?
FileReader fileReader = new FileReader (inputFilePath); FileWriter fileWriter = new FileWriter (outputFilePath); BR = new BufferedReader(fileReader);
/**
* We write out the matrices into the output file and create them to be reference matrix A
*/
int c; // raw int value from input
char nextChar; // input cast to char
long start = System.nanoTime(); //start of execution in nanoseconds
String line = BR.readLine();
while((c = fileReader.read()) != -1) {
nextChar = (char) c;
int m= line.length();
int[][]A = new int[m][m];
for (int i = 0; i < line.length(); i++) {
for (int j = 0; i < line.length(); j++) {
A[i][j] = nextChar;
}
}
String mat = "Determinant: " + A;
fileWriter.write(mat);
} // end while
解决方案
推荐阅读
- xml - 如何限制 XML 模式中选择组内的任何类型?
- sql - R Shiny:构建交互式 SQL 查询并将数据复制到全局环境中
- python - 如何在同一文件夹中的脚本之间使用 Python 导入,作为包的一部分导入,并在文件夹中作为独立脚本运行
- excel - 用于复制 csv 文件的 Excel 宏
- javascript - 如何在 django 中将数据从 index.html 发送到 views.py
- etl - 从单体应用到微服务的数据迁移 (Apache Airflow)
- nginx - 在没有端口的情况下访问 Istio 部署的网站
- javascript - 从switchMap rxjs中的商店选择器获取价值
- vue.js - 如何从Vue中的ElementUI“el-upload”获取文件名?
- flutter - Flutter中的异步Liquid Swipe?