Two Laptop Bag
The moose likes I/O and Streams and the fly likes Search File at all locations Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "Search File at all locations" Watch "Search File at all locations" New topic
Author

Search File at all locations

karan chandok
Greenhorn

Joined: Jul 15, 2011
Posts: 17
I am trying a program that can search file in all drives

But issue is it is searching for file only in current directory

Is there any way that I can find the file at all locations?

Thanks in Advance
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18370

Please KeepItDown. That doesn't include all uppercase letters but also larger fonts. It's completely unnecessary.

With java.io.File you can first use the static listRoots() methods to list all of the root files. You must then use a recursive method that for those. In pseudo code:
With java.nio.file.Path it's a bit different, because you can use FileVisitor:


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
 
subject: Search File at all locations
 
Threads others viewed
how to configure JBoss 5 in Eclipse 3.4 ?
How to find a file (any file) in Java
How to search specific file
B&S db file meta data, padding
rotating custom button, what paint method to ovveride
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture