Abs said:
I know how to get the user home directory with
System.getProperty("user.home"), but I cannot find any
system property to get the root directory in a file
tree. You know, the "My PC" in Windows or the "/" directory
in Unix. Is it possible with java ?
The "My Computer" pseudo-directory in Windows is not a real directory at
all... just a convention of sorts, so it's a little difficult to know
what you mean by "getting" it. You can get real filesystem roots with
the File class's static listRoots method. For Windows, though, that
will return the roots of all drives, not "My Computer".
If you're planning on displaying this to the user, as in a file
selection control, Swing provides a class called
javax.swing.filechooser.FileSystemView. You can get one through a
static factory method in that class. That class provides the virtual
sort of pseudo-filesystem that's actually presented to the user on most
Windows systems, along with things like conventional icons, human-
readable type descriptions, and other things that are useful for
providing a human interface to the filesystem.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation