This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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