Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to detect a given file in unknown directory  RSS feed

 
riyaz udeen
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hye everyone,

i want to know how to detect a given file in unknown directory. if iam given a file name & asked to find it in my system (under different directories on a particular drive or mulitple drives).hope you understand my question.

do reply thank u .

regards
riyaz
scjp 1.4
 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start at the root and get all the files/directories using File's list() mehtod. Search those files and continue thru all the directories until you find the file or there are no more directories to search.
 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you meant to ask: How to find all the drives on a system.
On Windows you can do a sequential search starting at A: and continue to the end of the alphabet.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a static "listRoots()" method in the java.io.File class which would tell you what drives are on your Windows system.

This is nothing like an advanced topic. I'm going to move it to the "I/O and Streams" forum for any follow-up.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!