java从一个较大的文本文档中查找字符串

java从一个较大的文本文档中查找字符串

 

public static void findStr(File fileParam) throws IOException{
    FileReader fread = null;
    BufferedReader bufferRead = null;
    fread = new FileReader(fileParam);
    bufferRead = new BufferedReader(fread);
    String lineStr = "";
    int lineNum=1;
    
    while((lineStr=bufferRead.readLine())!=null) {
        
        if(lineStr.contains("EPSILON")) {
            System.out.println("EPSILON----"+fileParam.getPath()+"  "+lineNum);
        }
        lineNum++;
    }
    bufferRead.close();
    fread.close();
    bufferRead = null;
    fread = null;
}

 

 

 

######################

posted @ 2022-12-09 17:46  西北逍遥  阅读(515)  评论(0编辑  收藏  举报