62,621
社区成员
发帖
与我相关
我的任务
分享package COM.LZJ;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
public class SelectNum {
File file = null;
BufferedReader br = null;
List list = null;
Pattern p = null ;
public static void main(String[] args) {
new SelectNum().go();
}
public void go(){
try {
file = new File("d:\\123.txt");
br = new BufferedReader(new FileReader(file));
list = new ArrayList();
String str;
while((str = br.readLine())!=null){
list.add(str);
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException w){
w.printStackTrace();
}
for(Iterator i = list.iterator();i.hasNext();){
String re = "\\d+";
p = Pattern.compile(re);
Matcher m = p.matcher("i.next()&&(i.next())trim()");
while(m.find()){
System.out.println(m.group());
}
}
}
}