源代码如下:

 1 import java.io.File;
 2 public class SpaceChecker
 3 {
 4      public static void main(String [] args)
 5      {
 6           File[] roots=File.listRoots();
 7            for(File  _file:roots)
 8             {
 9                   System.out.println(_file.getPath());
10                   System.out.println(_file.getName()); 
11                   System.out.println("可用空间:"+_file.getFreeSpace());
12                   System.out.println("已用空间:"+_file.getUsabelSpace());
13                   System.out.println("总空间:"+_file.getTotalSpace());
14              }
15        File win=new File("C:\\WINDOWS");
16        System.out.println(win.getPath());
17        System.out.println(win.getName());
18 System.out.println("可用空间:"+win.getFreeSpace()); 19 System.out.println("已用空间:"+win.getUsabelSpace()); 20 System.out.println("总空间:"+win.getTotalSpace()); 21 System.out.println(); 22 } 23 }

 

相关文章:

  • 2022-12-23
  • 2021-09-04
  • 2022-02-18
  • 2021-07-18
  • 2021-08-06
  • 2021-12-30
  • 2021-12-05
  • 2021-06-22
猜你喜欢
  • 2021-06-18
  • 2021-07-26
  • 2022-12-23
  • 2021-11-20
  • 2022-02-07
  • 2022-12-23
相关资源
相似解决方案