在一个为文本文件内有如下信息, 求编写一段程序把“每个”【申请号】后面的数字编号提取出来,谢谢了!--------------------------------第   1篇/共128453篇--------------------------------
【申请号】 85100001
【发明名称】 可变光学滤波实时假彩色显示装置
【【代理机构地址】 北京市海淀区中
【附图数】 4
【页数】 4
【权利要求项数】 6
【光盘卷号】
8609
8601
--------------------------------第   2篇/共128453篇--------------------------------
【申请号】 85100009
【发明名称】 拼音四角键盘盘面设计及输入方法
【页数】 0
【权利要求项数】 0
【光盘卷号】
8603
9015
--------------------------------第   3篇/共128453篇--------------------------------
【申请号】 85100013
【发明名称】 大幅黑白片实时假彩色化处理
【国家/省市】 天津(12)
【授权日】 1987年6月15日
【权利要求项数】 0
【光盘卷号】
8601

解决方案 »

  1.   


    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStreamReader;
    public class GetNo {
    public static void main(String[] args) throws IOException {
    File in = new File("d:\\data.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(in)));
    String temp = "";
    temp = br.readLine();
    while(null != temp && !"".equals(temp)) {
    if(temp.startsWith("【申请号】")) {
    int index = temp.indexOf("】");
    System.out.println(temp.substring(index + 1));
    }
    temp = br.readLine();
    }
    br.close();
    }
    }
      

  2.   


    public class Read {

    public static void main(String[] args) throws IOException {
    BufferedReader  br=new BufferedReader(
    new FileReader(new File("d:/1.txt")));
    String str="";
    while((str=br.readLine())!=null){
    if(str.indexOf("申请号")!=-1){
    System.out.println(str.substring(str.indexOf("】")+2));
    }
    }
    }}
      

  3.   

    public class Read {
        
        public static void main(String[] args) throws IOException {
            BufferedReader  br=new BufferedReader(
                    new FileReader(new File("d:/1.txt")));
            String str="";
            while((str=br.readLine())!=null){
                if(str.indexOf("申请号")!=-1){
                    System.out.println(str.substring(str.indexOf("】")+2));
                }
            }
                }}
      

  4.   

    if(str.indexOf("申请号")!=-1){
                    System.out.println(str.substring(str.indexOf("】")+2));
                }
    那个】地方没有空格,只是这上面显示的空格而已,你截取完之后要trim一下