Home > Java > javaTutorial > Example of Java calling DOS to implement scheduled shutdown

Example of Java calling DOS to implement scheduled shutdown

巴扎黑
Release: 2017-05-21 14:12:02
Original
1795 people have browsed it

Java calls DOS to implement scheduled shutdown. Friends who need it can refer to it

The code is as follows:

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();
         }
     }
Copy after login

The above is the detailed content of Example of Java calling DOS to implement scheduled shutdown. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template