一、System
- 获取环境变量
// static Map<String, String> System.getenv();//获取所有的环境变量 // static String System.getenv(String);//获取指定的环境变量
- 获取系统属性
// static Properties System.getProperties();//获取所有的系统属性 // static String System.getProperty(String);//获取指定的系统属性
- 获取系统当前时间
// static long System.currentTimeMills();//毫秒级 // static long System.nanoTime();//纳秒级
- 获取对象精确散列值
// static int System.identityHashCode(Object obj);
二、Runtime
Runtime runtime = Runtime.getRuntime();
- 获取处理器数量
/* *int availableProcessors(); */ runtime.availableProcessors();
- 获取空闲内存
/* *long freeMemory(); */ runtime.freeMemory();
- 获取总内存
/* *long totalMemory(); */ runtime.totalMemory();
- 获取可用内存
/* *long maxMemory(); */ runtime.maxMemory();
- 运行操作系统指令(可以在cmd控制台运行的指令)
/* *Process exec(String command); */ runtime.exec("notepad");