• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Search for a directory by its name only

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Till now I was using the following to find the existance of "myDirectory" directory:

File currentDir = new File("c:" + File.separator + myDirecory");
boolean dirExist = currentDir.isDirectory();

I would like to search myDirectoryon in my whole computer with just specifying its name (without a path).
Can I do that?

Thanks

Yossi
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. File has methods to determine the root drives. File also has methods to list out the contents of a particular file and whether the child is a file or a directory. If it is a directory, search it. If it is a file, compare its name to the one you want.
 
garfild Baram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, you are right, we have the File[] ff = File.listRoots();
The question here is how to iterate all root folders for a search of my specific folder?
What is the function that lists the content of folders in each root?
thanks man
Yossi
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's several. Have a look at the API documentation and look for the various list methods.
 
garfild Baram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Joe, I have found the solution for that :-)
reply
    Bookmark Topic Watch Topic
  • New Topic