文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>java计算磁盘空间的大小

java计算磁盘空间的大小

时间:2010-09-01  来源:开心无痕

    java计算磁盘空间的大小,jdk1.6下通过。

public class SpaceChecker {
     public static void main(String[] args) {
         File[] roots = File.listRoots();
         for (File _file : roots) {
             System.out.println(_file.getPath());
             //System.out.println(_file.getName());

             //System.out.println(.www.qichepeijian.com)
             System.out.println("Free space = " + _file.getFreeSpace());
             System.out.println("Usable space = " + _file.getUsableSpace());
             System.out.println("Total space = " + _file.getTotalSpace());
             System.out.println();
         }
        
        
         File win = new File("C:\\WINDOWS");
         System.out.println(win.getPath());
         System.out.println(win.getName());
         System.out.println("Free space = " + win.getFreeSpace());
         System.out.println("Usable space = " + win.getUsableSpace());
         System.out.println("Total space = " + win.getTotalSpace());
         System.out.println();
     }
}
运行结果:

D:\java>java SpaceChecker
A:\
Free space = 0
Usable space = 0
Total space = 0

C:\
Free space = 995975168
Usable space = 995975168
Total space = 4301590528

D:\
Free space = 4041146368
Usable space = 4041146368
Total space = 10756333568

E:\
Free space = 10000908288
Usable space = 10000908288
Total space = 26012024832

F:\
Free space = 0
Usable space = 0
Total space = 0

C:\WINDOWS
WINDOWS
Free space = 995975168
Usable space = 995975168
Total space = 4301590528

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载