本文介绍了如何获取所有驱动器的列表,但也获得相应的驱动器类型(可移动,本地磁盘或CD-ROM,DVD-ROM等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取列表所有驱动器,但也获得相应的驱动器类型(可移动,本地磁盘或CD-ROM,DVD-ROM等)?
How can I get list all drives but also get the corresponding drive type (removable,local disk, or cd-rom,dvd-rom... etc)?
推荐答案
使用此代码,您可以获取所有驱动器及其类型说明
With this code you can get all drives and its type description
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));
}
这篇关于如何获取所有驱动器的列表,但也获得相应的驱动器类型(可移动,本地磁盘或CD-ROM,DVD-ROM等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!