java范例

          java

          正則表達小示例

          package com.together.img;

          import java.io.BufferedReader;
          import java.io.FileNotFoundException;
          import java.io.FileReader;
          import java.io.IOException;
          import java.util.regex.Matcher;
          import java.util.regex.Pattern;


          public class ImageSpider {

           public static void main(String[] args) {
            try {
             BufferedReader br = new BufferedReader(new FileReader("c://date.jsp"));
             String line = "";
             while((line=br.readLine()) != null) {
              System.out.println("line:"+line);
              parse(line);
             }
            } catch (FileNotFoundException e) {
             e.printStackTrace();
            } catch (IOException e) {
             e.printStackTrace();
            }
           }

           private static void parse(String line) {
            Pattern p = Pattern.compile("[\\[file:///]+\\w+[|/]+\\w+\\.png+");
            Matcher m = p.matcher(line);
            while(m.find()) {
                System.out.println(m.group());
            }
           }


          }

          posted on 2007-10-26 13:36 王波 閱讀(163) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 本溪| 澎湖县| 廊坊市| 曲周县| 久治县| 惠安县| 阿鲁科尔沁旗| 桑日县| 仙桃市| 弥渡县| 嫩江县| 固始县| 林芝县| 清水县| 河源市| 万盛区| 堆龙德庆县| 涞水县| 罗定市| 东安县| 大洼县| SHOW| 梁河县| 平塘县| 肥西县| 谢通门县| 巴南区| 金山区| 旬阳县| 土默特右旗| 息烽县| 四子王旗| 冷水江市| 天祝| 虞城县| 凤翔县| 青铜峡市| 镇宁| 石柱| 黄陵县| 个旧市|