我正在尝试从文本文件中提取数据,如下所示:
xxxxxxxxxxxx
xx.x.x.x.xxx
xx.x.x.x.xxx
xx.xBx.x.xxx
xx.x.xCx.xxx
xxAx.x.xDxxx
xxxxxxxxxxxx
xx.x.x.x.xxx
xx.xBx.x.xxx
xx.x.x.x.xxx
xxAx.x.x.xxx
xx.x.xCxDxxx
xxxxxxxxxxxx
xxAx.x.x.xxx
xx.x.x.xDxxx
xx.xBx.x.xxx
xx.x.xCx.xxx
xx.x.x.x.xxx
我想将行间距之前的每个组保存到单独的数组或矩阵中。我想出了这个,但无法弄清楚如何继续:
List<String[]> arrays = new ArrayList<String[]>();
try {
BufferedReader in = new BufferedReader(new FileReader("K:\\elevator0.txt"));
String str;
while ((str = in.readLine()) != null) {
String arr[] = str.split("\n");
if(arr.length>0) arrays.add(arr);
}
in.close();
} catch (IOException e) {
}int i=0;
for(String a[]:arrays)
{
i=0;
System.out.println(a[i]);
i++;
}