Results 1 to 7 of 7
Thread: How to know system folder path
- 11-20-2008, 09:26 AM #1
Member
- Join Date
- Nov 2008
- Posts
- 13
- Rep Power
- 0
- 11-20-2008, 09:29 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Take a look at the API docs for File.
- 11-20-2008, 09:52 AM #3
import java.io.*;
public class DirListing1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Boolean flag=false;
File f =new File("e:/");
String [] s=f.list();
for(int index =0 ; index<s.length;index++){
if(s[index].equals("e:/xxx")){
flag=true;
}
System.out.println(s[index]);
}
}
}
- 11-20-2008, 11:53 PM #4
@DevzAbhi's code fragment starts with the explicit statement to look on E:
If the real question is: I have a directory somewhere, and its called XXX, how do I find it?
This is harder, because the concept of an E: drive is Windows specific,
You could, altho its crude, just run through a loop of all drive letters, A through Z, but with UNC names, that isn't guarenteed to be complete
- 11-21-2008, 05:41 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I'm not clear what you are asking here. Are you want to find that a specific folder(as you said xxx) is located on drive E or not? So you have to search recursively all drives in the system.
But as fishtoprecords says, it's Widows specific, in UNC systems you don't have drive letters to find.
- 11-21-2008, 06:33 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
I said to look at File, because, if you do getParentFile() until it returns null, the "File" for which it returned null is the root for the File you started with.
- 11-21-2008, 08:08 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
How to create Folder View
By jazz2k8 in forum Advanced JavaReplies: 2Last Post: 10-24-2008, 02:04 PM -
want to run my code from any folder ?
By Shyam Singh in forum New To JavaReplies: 1Last Post: 08-12-2008, 01:31 PM -
folder cloning
By jad in forum Advanced JavaReplies: 1Last Post: 07-01-2008, 12:28 AM -
add password to folder
By ismailsaleh in forum AWT / SwingReplies: 1Last Post: 01-08-2008, 05:46 AM -
creation of new folder in the mail
By an8086 in forum Advanced JavaReplies: 1Last Post: 07-15-2007, 05:10 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks