BufferedReader br = new BufferedReader(new FileReader("test.java"));
String pattern = "\\".*?\\"";
String line = "";
while((line = br.readLine())!=null){
Matcher match = Pattern.compile(pattern).matcher(line);
while(match.find()){
System.out.println(match.group());
}
}
br.close();
String pattern = "\\".*?\\"";
String line = "";
while((line = br.readLine())!=null){
Matcher match = Pattern.compile(pattern).matcher(line);
while(match.find()){
System.out.println(match.group());
}
}
br.close();
String pattern = ".*new CSSException\\((.*)\\);.*";
Pattern p = Pattern.compile(pattern);
String line = null;
while((line = br.readLine())!=null){
System.out.println(line);
Matcher m = p.matcher(line);
if (m.matches()){
System.out.println(m.group(m.groupCount()));
}
}
br.close();
"ID号\"
" + id + "
"已存在"
看看谁还有更好的办法啊,观望中……