Java调用DOS命令实现关机

 1 public static void shutdown(){
 2         
 3         System.out.print("请输入多少分钟后关机:");
 4         Scanner scanner = new Scanner(System.in);
 5         int minute = scanner.nextInt()*60;
 6         Runtime runtime = Runtime.getRuntime();
 7         String shutdown = "shutdown -s -t "+minute;
 8         try {
 9             runtime.exec(shutdown);
10         } catch (IOException e) {
11             e.printStackTrace();
12         }
13     }
posted @ 2013-04-15 00:20  hacket520  阅读(322)  评论(0编辑  收藏  举报