我在文件中有一个数字列表,其格式为 106,648|403,481。我必须添加此列表的所有第二个坐标并需要总和。我可以使用 | 拆分此列表 但是当我尝试使用 拆分它们时,它不起作用。到目前为止,我已经这样做了。请有人帮我...
package org.jeet.App;
import java.io.*;
import java.util.*;
public class MidPointSum {
public static void main(String[] args) {
File file = new File("D:/midpoint.txt");
try {
Scanner sc = new Scanner(file);
while (sc.hasNext()) {
String value = sc.next();
int myint[] = new int[2];
String[] tokens = value.split("\\|");
for (int i = 0; i < tokens.length; i++) {
System.out.println(tokens[i]);
//System.out.println(charSplit[i]);
}
}
} catch (FileNotFoundException e) {
System.err.println("File is not Found");
} catch (Exception e) {
System.err.println("Another Exception");
}
}
}
请帮我将数字拆分为
106 648 403 481 .. 等等