String pathname = "F:\\Calibration.txt";
try (FileReader reader = new FileReader(pathname);
BufferedReader br = new BufferedReader(reader)) {
String line;
while ((line = br.readLine()) != null) {
String[] split = line.split(",");
System.out.println(split[0]);
}
此代码可以获取第一列的内容
,但列不固定。
我想 - 按列数自动获取每列的数据
不使用像这样的修复数字 split[fixNumber]
27311,28841,30577,31583,0
26401,28046,30234,31255,50
25495,27263,29891,30926,100
24594,26494,29548,30597,150
23696,25737,29206,30269,200
这是 Calibration.txt 的内容
预期输出:
27311 26401 25495 24594 23696
colmun 不固定,我不想使用 split[0] 或 (split[1] split[2]...)
这是我的新代码:
List<String> list = new ArrayList();
String pathname = "F:\\Calibration.txt";
try (FileReader reader = new FileReader(pathname);
BufferedReader br = new BufferedReader(reader))
{
String line;
while ((line = br.readLine()) != null) {
list.add(line);
}
for(int i = 0; i < list.size(); i++) {
System.out.println(i);
for(String a : list){
String[] regex = a.split(",");
System.err.println(regex[i]);
}
}
HUH函数
相关分类