public static void lkm(){
FileSystemView fileSystemView = FileSystemView.getFileSystemView();// 获取FileSystemView对象
File[] roots = File.listRoots();
for (File file : roots) {
String pathName = file.getPath();// 获取磁盘的路径名称
String diskName = fileSystemView.getSystemTypeDescription(file);// 获取磁盘的类型描述信息
System.out.println("磁盘名称为:" + diskName + pathName);
//判断是否存在C盘、D盘
if(pathName.equals("D:\\")){
System.out.println("磁盘名称为:" + diskName + pathName);
}else if(pathName.equals("C:\\")){
System.out.println("磁盘名称为:" + diskName + pathName);
}
}
}
04-24
956
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23