tags:

views:

88

answers:

2

How do I get all the system devices in a list of Files or Strings.

+1  A: 

You have to call the static method: File.listRoots();

Martijn Courteaux
A: 

If you are asking how to identify all of the Unix/Linux device "files" in a list of Files, then I think the answer is that you can't.

The File.isFile() and File.isDirectory() methods can tell you if a File is a regular file or a directory. If you use File.getCanonicalFile() you can distinguish symbolic links.

But this still leaves character device files, block devices files, FIFOs (named pipes) and Unix domain sockets. AFAIK, you cannot distinguish these cases using pure Java.

Stephen C