java 获取系统信息(CPU,内存,硬盘,进程)的相关方法 一、这是一个获取相关信息的简单的方法 import java
*; import com
management
OperatingSystemMXBean; import sun
management
ManagementFactory; public class Tst{ public static String pt="D:\\abc
txt"; public Tst(){ } public static void main(String[] args) throws Exception{ //free 和 use 和 total 均为 KB long free=0; long use=0; long total=0; int kb=1024; Runtime rt=Runtime
getRuntime(); total=rt
totalMemory(); free=rt
freeMemory(); use=total-free; System
println("系统内存已用的空间为:"+use/kb+" MB"); System
println("系统内存的空闲空间为:"+free/kb+" MB"); System
println("系统总内存空间为:"+total/kb+" MB"); OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory
getOperatingSystemMXBean(); long physicalFree=osmxb
getFreePhysicalMemorySize()/kb; long physicalTotal=osmxb
getTotalPhys