Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Search For File

 
kayanaat sidiqui
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Following is the directory structure in which i need to llok for the files.



I need to search for the files which exist only in "FOL".

As you can notice easily that it's not necessary that every directory must contain "FOL".

What i need just take input as file name from user and look for those file in FOL.
What we already know that root path of above directory that is path where above directory exist.

Is there any better and faster way to do this?

Thanks,
Kaya.


 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please edit your post to add code tags; it will preserve the spaces in your diagram.

I have only ever sen it done recursively, using the methods of the File class. Remember that File can refer to a directory as well as an ordinary file, so you can get an array of contained files in a directory. You can check whether the name of a file ends with "FOL" using the methods of the String class, if necessary. You can also put a filter on a search.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better or faster way than what?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic