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

file parsing in drive (how many drives )

 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

could u guys suggest s for below criteria ?.

i need to parse all files in my hard disk.
As of now i can able to parse the specific drive , which i am giving explicitly in my code in my file object .

all i need a code to get how many drives .Since place where my code executes , i cant able to pre think how many drives are there?.

Please suggest a idea or link

Thanks ,
gowtham
grgowtham_cse@yahoo.com
eprosoft Inc
NJ
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The listRoots() method in the File class returns all available roots on the system as an array of File instances. Note that these might not necessarily be physical drives though (they might be networked drives etc).
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stuart Gray:
The listRoots() method in the File class returns all available roots on the system as an array of File instances. Note that these might not necessarily be physical drives though (they might be networked drives etc).


Could u Pls find where i am going wrong




Thanks ,
gowtham
grgowtham_cse@yahoo.com
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stuart Gray
i need a code which o/p c:\ or d:\ howmany drives
Thanks,
gowtham
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops finally ...

public static void main(String args[])
{
File list[] = File.listRoots();
for (int i = 0; i < list.length; i++) {

System.out.println("not accessible:"
+ list[i]);
}

This does my Work.
Thanks
Gowtham
grgowtham_cse@yahoo.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic