代码如下:- 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());
- }
- }
- }
- }
复制代码 大神门帮忙看看吧 小弟在此感激不尽~不知道哪错了
|