我想从文件中读取每一行并只编辑显示来自特定服务器的 url 的行......我的代码就像......
Scanner ReadIsbn = new Scanner (new FileReader ("C:/Users/...."));
Pattern pat = Pattern.compile("http:////www.librarything.com//isbn//");
while ( ReadIsbn.hasNextLine()){
String line = ReadIsbn.nextLine();
Matcher m = pat.matcher(line);
if (m.matches() == true) {
EDIT line....
}
}
}
而且它不起作用......事实上 m.matches() 总是错误的......在我作为输入提供的文件中,有如下行:
1) http://www.librarything.com/isbn/0-9616696-7-5.html
2) http://www.librarything.com/isbn/0-86078-322-7.html
Cultural tourism : how the arts can help market tourism products, how
blablabla
(我只想编辑示例的前两行)