黑马程序员技术交流社区
标题:
java关机重启代码
[打印本页]
作者:
罗忠文
时间:
2012-11-25 10:28
标题:
java关机重启代码
import java.io.IOException;
public class ShutDown {
public static void shutDownAtTime(String time){
Runtime run=Runtime.getRuntime();
try {
run.exec("at "+time+" Shutdown -s");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void shutDownHaveTime(String time){
Runtime run=Runtime.getRuntime();
try {
run.exec("Shutdown.exe -s -t "+time);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void shutDownAtNow(){
Runtime run=Runtime.getRuntime();
try {
run.exec("Shutdown.exe -s");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void reboot(){
Runtime run=Runtime.getRuntime();
try {
run.exec("Shutdown.exe -r");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void shutDownHaveTimeWithMess(String time,String mes){
Runtime run=Runtime.getRuntime();
try {
run.exec("shutdown -s -t "+time+" -c""+mes+""");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void noShutDown(){
Runtime run=Runtime.getRuntime();
try {
run.exec("shutdown -a");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
作者:
许庭洲
时间:
2012-11-25 21:39
值得学习ing!
作者:
罗忠文
时间:
2012-11-25 21:51
许庭洲 发表于 2012-11-25 21:39
值得学习ing!
谢谢,你是不很牛啦
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2