aspose file tools*
The moose likes Beginning Java and the fly likes Search For File 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 » Beginning Java
Bookmark "Search For File " Watch "Search For File " New topic
Author

Search For File

kayanaat sidiqui
Ranch Hand

Joined: Sep 04, 2008
Posts: 122
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

Joined: Oct 13, 2005
Posts: 39393
    
  28
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

Joined: Sep 29, 2008
Posts: 12617

Better or faster way than what?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Search For File