如何用JAVA提取文本文档的多个数据
发布网友
发布时间:2022-04-25 07:16
我来回答
共1个回答
热心网友
时间:2022-05-03 04:13
The following example illustrates how the String.split method can be used to break up a string into its basic tokens:
String[] result = "this is a line read from txt file".split("\\s");
for (int x=0; x<result.length; x++)
System.out.println(result[x]);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
String[] result = "123 321 -1 555".split("\\s");
for (int x=0; x<result.length; x++){
int value= -999999; //default
try{
value= Integer.parseInt(result[x]);
}catch (Exception e){}
System.out.println(value);
}