我正在尝试使用 Java 获取 Windows 上当前插入的存储驱动器的列表。
这是我在 StackOverflow 上的另一个问题中找到的代码片段:
File[] paths;
FileSystemView fsv = FileSystemView.getFileSystemView();
// returns pathnames for files and directory
paths = File.listRoots();
// for each pathname in pathname array
for(File path:paths)
{
// prints file and directory paths
System.out.println("Drive Name: "+path);
System.out.println("Description: "+fsv.getSystemTypeDescription(path));
}
Run Code Online (Sandbox Code Playgroud)
问题实际上是我无法以某种方式使用 FileSystemView 并且我也无法导入它的库...可能是因为我正在使用 JavaFX?有没有可能解决这个问题?
先感谢您!