- import java.io.IOException;
- import java.util.Scanner;
- public class ShutdownConsole{
-
- public static void main(String[] args){
- shutdown();
- }
- public static void shutdown(){
-
- System.out.print("请输入多少分钟后关机:");
- Scanner scanner = new Scanner(System.in);
- int minute = scanner.nextInt()*60;
- Runtime runtime = Runtime.getRuntime();
- String shutdown = "shutdown -s -t "+minute;
- try {
- runtime.exec(shutdown);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
复制代码 |
|