获得window下的所有盘符


获得window下的所有盘符:

File[] files = File.listRoots();   
for(File f : files){   
    System.out.println(f.getPath());   
}   
  
//验证是否为Window操作系统   
if(System.getProperties().getProperty("os.name").contains("Window"))   
{                                   
      //默认根目录为C盘  
    currentParentDir="C:"+System.getProperties().getProperty("file.separator"); 
      isWindowOS=true;   
}else{                             
      //获得当前操作系统的文件分隔符
    currentParentDir=System.getProperties().getProperty("file.separator");   
}