Create a java program to search for specific word files

I'm just learning that language and want to know what experience Java programmers will have in the following situations?

I want to create a java program that will search all instances of a specific word in a specified file

How do you solve this problem? Does the Java API provide a class that provides file scanning function, or do I have to write my own class to perform this operation?

Thank you for any comments, cathedral

Solution

The Java API provides Java util. Scannerclass, which allows you to scan input files

However, depending on how you intend to use it, this may not be the best idea Is the file very large? Are you searching for only one file, or are you trying to keep a database of many files and search for files in it? In this case, you may want to use a richer engine, such as Lucene

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>