1.Runtime类
1.案例:
public class RunTimeDemo {
public static void main(String[] args) throws IOException {
//创建当前运行环境的实例
Runtime runtime = Runtime.getRuntime() ;
//获取计算机cpu的处理器数量
//public int availableProcessors()
System.out.println(runtime.availableProcessors());
//操作指令
// public Process exec(String command) throws IOException
// System.out.println(runtime.exec("calc")); //打开计算器
// System.out.println(runtime.exec("mspaint")); //打开计算器
// runtime.exec("notepad") ;
// runtime.exec("qq") ;
//关机指令
// runtime.exec("shutdown -s -t 300") ; //300秒后关机
runtime.exec("shutdown -a") ; //取消关机
}
}