I'm writing a disk crawler and if the user doesn't provide an existing path the program should search all disks that are available. Does anybody know is it possible and if it is how to do that from Java?

有帮助吗?

解决方案

Try this:

File.listRoots();

其他提示

Only works on windows, on unix based operating system you will have 1 root, independent of the number of disks.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top