• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

homework question file search

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



 
anon anony
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic