Shutting down windows operating system by Java
public class Main
{
public static void main(String[] args) throws IOException
{
String shutdownCommand="";
String operatingSystem = System.getProperty("os.name");
if ("Linux".equals(operatingSystem) || "Mac OS X".equals(operatingSystem))
{
shutdownCommand = "shutdown -h now";
}
else if (operatingSystem.startWith("Window"))
{
shutdownCommand = "shutdown -s -t 0";
}
Runtime.getRuntime().exec(shutdownCommand);
System.exit(0);
}
}
留言
張貼留言