我需要在一个非常大的文本文件(5-10 to )中找到一个子字符串。对于这种大小的文件处理,您有什么建议?
UPD:这个算法在文件中搜索一个单词,但在我看来vryat它可以很容易地处理大文件:
File textFile = new File("text.txt");
BufferedReader fileOut = new BufferedReader(new FileReader( textFile ) );
String s;
int a = 1;
while((s = fileOut.readLine()) != null) {
if(s.contains("findword"))
System.out.println(a + ": " + s);
a++;
}
fileOut.close();发布于 2015-01-28 07:15:08
提示:看看Knuth-Morris-Pratt算法。
https://stackoverflow.com/questions/28126906
复制相似问题