如题 求解
------解决方案--------------------
假如你的U盘在电脑上显示的是F盘
- Java code
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;}}