/**
* @author leaf
* java关机程序
*/
package test;
import java.io.IOException;
import java.util.Scanner;
public class ShutDown {
//关机定时
public static final String time="60";
//关机方法
public void shutdown(){
try {
System.out.println("你确定关机吗? y/n");
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
if(s.equalsIgnoreCase("y")){
//关机
Runtime.getRuntime().exec("shutdown /s /t "+time);
}
System.out.println("输入'q'取消关机");
s=sc.nextLine();
if(s.equalsIgnoreCase("q")){
//取消关机
Runtime.getRuntime().exec("shutdown /a");
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String args[]){
new ShutDown().shutdown();}
}
* @author leaf
* java关机程序
*/
package test;
import java.io.IOException;
import java.util.Scanner;
public class ShutDown {
//关机定时
public static final String time="60";
//关机方法
public void shutdown(){
try {
System.out.println("你确定关机吗? y/n");
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
if(s.equalsIgnoreCase("y")){
//关机
Runtime.getRuntime().exec("shutdown /s /t "+time);
}
System.out.println("输入'q'取消关机");
s=sc.nextLine();
if(s.equalsIgnoreCase("q")){
//取消关机
Runtime.getRuntime().exec("shutdown /a");
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String args[]){
new ShutDown().shutdown();}
}