misaki-workshop

这是我第一个Java程序,虽然之前学过Java,但没怎么实际应用过

自动关机主要使用到两个命令

// second为自定义秒数,为整数
shutdown -s -t second
// 取消自动关机
shutdown -a

以下是main函数

 1     public static void main(String[] args) throws IOException {
 2         // TODO Auto-generated method stub
 3         //    关机
 4         System.out.println("自动关机");
 5         System.out.println("输入秒数设置自动关机:");
 6         @SuppressWarnings("resource")
 7         Scanner input = new Scanner(System.in);
 8         String x = input.nextLine();
 9         Runtime.getRuntime().exec("shutdown -s -t " + x);
10         System.out.println("将在"+x+"秒后自动关机");
11         //    取消关机
12 //        Runtime.getRuntime().exec("shutdown -a");
13 //        System.out.println("取消关机");
14     }

 

分类:

技术点:

相关文章:

  • 2021-10-09
  • 2021-11-30
  • 2021-11-30
  • 2021-12-03
  • 2021-12-15
  • 2021-11-23
  • 2021-11-05
猜你喜欢
  • 2021-08-29
  • 2022-12-23
  • 2021-11-23
  • 2021-12-07
  • 2021-11-30
  • 2022-01-05
  • 2021-09-16
相关资源
相似解决方案