package find_text; public class ReadFileChild extends ReadFile { private String text; private boolean zhiChiRegex; public ReadFileChild(String text) { super(); this.text = text; this.zhiChiRegex = true; } public ReadFileChild(String text, boolean zhiChiRegex) { super(); this.text = text; this.zhiChiRegex = zhiChiRegex; } public ReadFileChild() { } @Override public String chuLi(String str) { rowNum++; if(zhiChiRegex){//提供了对正则表达式的支持 if(str.matches(text)||true){ System.out.println(str+"+++==="+text); System.out.println(fileName+" 第"+rowNum+"行: "+str); return rowNum+""; } //return null; }else{ if(str.contains(text)){ System.out.println(fileName+" 第"+rowNum+"行: "+str); return rowNum+""; } //return null; } return null; } public String getText() { return text; } public void setText(String text) { this.text = text; } }
最近下载更多