File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Search through files - API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Search through files - API " Watch "Search through files - API " New topic

Search through files - API

ksp shenoy

Joined: Jun 20, 2004
Posts: 4
Hi all,

I need to implement a search feature in one of my jsp application. Here, user inputs the search keyword and the application has search through all the files stored on the server and list out all the files containg the given keyword...So, is there any specific java API for this..? Or I need to read each and every file to look for the key the second case, the process will take more time to perfom the search and seems to be less efficient...So, kindly help in this regards..

Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Perhaps you can invoke 'grep' from java, which is quite fast and handles some kind of regularexpressions.
grep is freely available for most unixes as far as I know and for windows too.
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

There's an implementation of grep in the New IO Examples. Should be reasonably fast. Perhaps you can bend it to your needs.

[How To Ask Questions On JavaRanch]
ksp shenoy

Joined: Jun 20, 2004
Posts: 4
Thanx for the tips
I agree. Here's the link:
subject: Search through files - API
It's not a secret anymore!