Java Code to Shutdown The Computer - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Monday, September 25, 2017

Java Code to Shutdown The Computer

Write a Java Code to Shutdown The Computer


Program:
import java.io.*;

public class JavaProgram
{
public static void main(String args[]) throws IOException
{
Runtime runtime = Runtime.getRuntime();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter No. of Seconds after which You want your Computer to Shutdown :");
long a=Long.parseLong(br.readLine());

Process proc = runtime.exec("shutdown -s -t " +a);

System.exit(0);
}

}

No comments:

Post a Comment