File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

searching a content in a file

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

suppose,there are(example D drive) some files which are having paragraph ...

if i give some word in search button..then i submit..now i want the file/files which is having the particular word...

how to do it?

please anyone can explain me

thanks & regards,
seetharaman
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is an example of a recursive method - if the File is a directory, the same method is called with the new File. This will end if either a File is a file or a directory is empty; then the next File will be searched.

That leaves the implementation of the contains method. You'll have to read in each line and check for presence until the word is found. Look for BufferedReader and its readLine method for reading the File. You can use String's indexOf method to check if the word is present.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apache lucene is a good text search engine if you need a thrid party library to do the search for you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic