File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes homework question file search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "homework question file search" Watch "homework question file search" New topic
Author

homework question file search

anon anony
Greenhorn

Joined: Apr 08, 2011
Posts: 2
Hello everyone, its my first time here. Nice to meet everyone. This is the question;
Write a program Find that searches all files specified on the command line and prints out all lines containing a reserved word. Start a new thread for each file. So by just reading each file individually and using each one in a different thread so they could all be read at once basically?

Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2503
    
    8

Welcome to the Ranch, Casey.

casey provost wrote:...
So I am unsure how to begin with this code, do I basically search through a file?
Thanks everyone.


Yes. You read each file (in a separate thread, as indicated by your assignment) line per line.
Every time you find the reserved word in a line, you print that line.
Keep on reading untill you reach the end of the file.


You could also implement a FilterReader.
As in this example.




OCUP UML fundamental and ITIL foundation
youtube channel
anon anony
Greenhorn

Joined: Apr 08, 2011
Posts: 2
I think I could use the FilterReader, never tried it before I just have to make sure I am using multithreading. I think I understand what to do now though, thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: homework question file search