Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get the user's drive and path? 1

Status
Not open for further replies.

tonioJ

Programmer
Oct 7, 2002
90
PH
Does anyone has a sample codes on getting the drives in a local computer and the path? Please help.
 
hello sedj,
thank you for the help. i have tried it. it works. but i still have one more problem, how do it convert it to string. because the data type File. I can't convert it to string. is there anyway to do it?
 
how do I do it? I have tried it but I'm getting an error.

String myStr = "";

File f = new File("/");
File[] fs = f.listRoots();
for (int i = 0; i < fs.length; i++) {
System.err.println(fs);
}
myStr = fs[0].toString();
System.println(myStr);


what's wrong with my code?

 
Code:
		File f = new File("/");
		File[] fs = f.listRoots();
		for (int i = 0; i < fs.length; i++) {
			String fileString = fs[i].toString();
			System.err.println(fileString);
		}
 
hi sedj,
it worked now. thanks a lot! helped me in my quest to learned java programming. i am on self study basis. thanks a lot pal.. :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top