创建Java程序以搜索特定Word的文件 [英] Creating a Java Program to Search a File for a Specific Word

查看:164
本文介绍了创建Java程序以搜索特定Word的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在学习那种语言,并想知道Java程序员在以下情况下会有什么经验?

I am just learning that language and was wondering what a more experience Java programmer would do in the following situation?

我想创建一个java程序,在指定文件中搜索特定单词的所有实例。

I would like to create a java program that will search a specified file for all instanced for a specific word.

你会如何解决这个问题,Java API是否提供了一个提供文件扫描功能的类,或者我必须编写自己的类来执行此操作?

How would you go about this, does that Java API come with a class that provides file scanning capabilities or would i have to write my own class to do this?

感谢任何输入,

Dom。

Thanks for any input,
Dom.

推荐答案

java API确实提供了 java.util.Scanner 类,它允许您扫描输入文件。

The java API does offer the java.util.Scannerclass which will allow you to scan across an input file.

然而,根据您打算如何使用它,这可能不是最好的主意。文件非常大吗?您是只搜索一个文件还是试图保留许多文件的数据库并在其中搜索文件?在这种情况下,您可能希望使用更加丰富的引擎,例如 lucene

Depending on how you intend to use this, however, this might not be the best idea. Is the file very large? Are you searching only one file or are you trying to keep a database of many files and search for files within that? In that case, you might want to use a more fleshed out engine such as lucene.

这篇关于创建Java程序以搜索特定Word的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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