Pages

Wednesday 19 February 2014

Java Program To Shutdown Computer

This is a simple Java program for shutdown the computer.

This program is used when you make a application that will run for an hour and you don't wait to shutdown your computer, just add this code at last of your application. Your computer will automatically shutdown when your application is over. You can use it more place also.


Here is the code :
------------------------------------------------------------------------------------------------------------
public class ShutdownComputer {

    public static void main(String[] args) throws IOException {
        Runtime runtime = Runtime.getRuntime();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Process proc = runtime.exec("shutdown -s -t 30"); // after 30 second it will shoutdown
        System.exit(0);

    }
}
--------------------------------------------------------------------------------------------------------------

COMMENT IF YOU HAVE ANY COMPUTER TRICKS.

No comments:

Post a Comment