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 }