/*
//这里面单例饿汉式
//Runtime的源码
public class Runtime {
private static final Runtime currentRuntime = new Runtime();
public static Runtime getRuntime() {
return currentRuntime;
}
private Runtime() {
}
*
* */
import java.io.IOException;
//每个Java应用程序都有一个Runtime类的Runtime ,允许应用程序与运行应用程序的环境相连接
public class RuntimeDemo {
public static void main(String[] args) throws IOException {
Runtime r=Runtime.getRuntime();
// r.exec("calc");//打开计算器
// r.exec("notepad");//打开记事本
// r.exec("shutdown -s -t 10000"); //关机
r.exec("shutdown -a");//取消关机
}
}
Runtime类可执行windows控制台命令
最新推荐文章于 2023-11-08 17:54:23 发布