当前位置:编程学习 > JAVA >>

java开发_Runtime

public static void main(String[] a){
         Runtime runtime = Runtime.getRuntime();
         long freeMemoery = runtime.freeMemory();
         long totalMemory = runtime.totalMemory();
         long usedMemory = totalMemory - freeMemoery;
         long maxMemory = runtime.maxMemory();
         long useableMemory = maxMemory - totalMemory + freeMemoery;
        
         System.out.println("当前时间:"+runtime);
         System.out.println("系统闲置空间:"+freeMemoery);
         System.out.println("系统总空间:"+totalMemory);
         System.out.println("系统被用的空间:"+usedMemory);
         System.out.println("系统最大空间:"+maxMemory);
         System.out.println("系统可用空间:"+useableMemory);
     }
运行效果:


当前时间:www.zzzyk.com
 系统闲置空间:4873672
 系统总空间:5177344
 系统被用的空间:303672
 系统最大空间:66650112
 系统可用空间:66346440
 

 作者:张慧

补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,