日期:2014-05-20 浏览次数:20653 次
import java.io.*; public class GetUdisk { public static void main(String[] args) { System.out.println(getUdisk()); } public static String getUdisk() { String str=null; String dirName="F:/"; File win=new File(dirName); if(win.exists()) { long total=(long)win.getTotalSpace(); long free=(long)win.getFreeSpace(); Double compare=(Double)(1-free*1.0/total)*100; str="F:盘 已使用 "+compare.intValue()+"%"; } return str; } }