我n.txt
在格式的文本文件中有整数,2 列整数,各列用空格分隔。
我想读取这些整数并转义它们之间的空格并将这两个整数输入到 2 个单独的整数中。下面的代码用于解析String
获得的。我想知道是否有任何String
方法可以将它们拆分String
为单独的数组并使用空白空间作为分隔符?
String URL="C:\\User\\Nimit\\Desktop\\n.txt";
File f = new File(URL);
FileReader inputF = new FileReader(f);
BufferedReader in = new BufferedReader(inputF);
int[] a= new int [1000];
int[] b= new int [1000];
String s =in.readLine();
while(s!=null)
{
int i = 0;
a[i] = Integer.parseInt(s,b[i]); //this is line 19
//*not important*// System.out.println(a[i]);
s = in.readLine();
}
in.close();
System.out.println("the output of the file is " +f);