使用java在文本文件中查找字符串的最快方法 [英] Fastest way to find a string in a text file with java

查看:792
本文介绍了使用java在文本文件中查找字符串的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


推荐答案

查看一个文件是否包含特定的字符串或数字是最快的方法 Scanner 类,附带JDK(查看官方文档)。您将能够跳过某些输入部分(在这种情况下是文本文件),并匹配您的愿望的正则表达式。我不确定这是否是最有效的方法,但是肯定 - 这很简单。你也可以看看这个例子,这将帮助你开始。

Have a look at the Scanner class, that ships with JDK (See official documentation). You will be able to skip certain parts of input (in this case - text file) and match against regular expression of your desire. I'm not sure if this is the most efficient way, but sure enough - it's pretty simple. You might also take a look at this example, which will help you get started.

这篇关于使用java在文本文件中查找字符串的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆