A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 罗忠文 中级黑马   /  2012-11-25 10:28  /  1252 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

import java.io.IOException;

public class ShutDown {

public static void shutDownAtTime(String time){
  Runtime run=Runtime.getRuntime();
  try {
   run.exec("at "+time+" Shutdown -s");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
}

public static void shutDownHaveTime(String time){
  Runtime run=Runtime.getRuntime();
  try {
   run.exec("Shutdown.exe -s -t "+time);
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
}

public static void shutDownAtNow(){
  Runtime run=Runtime.getRuntime();
  try {
   run.exec("Shutdown.exe -s");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
}

public static void reboot(){
  Runtime run=Runtime.getRuntime();
  try {
   run.exec("Shutdown.exe -r");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
}

public static void shutDownHaveTimeWithMess(String time,String mes){
  Runtime run=Runtime.getRuntime();
  try {
   run.exec("shutdown -s -t "+time+" -c""+mes+""");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
}

public static void noShutDown(){
  Runtime run=Runtime.getRuntime();
  try {
   run.exec("shutdown -a");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
}


评分

参与人数 1技术分 +1 收起 理由
古银平 + 1 赞一个!

查看全部评分

2 个回复

倒序浏览
值得学习ing!
回复 使用道具 举报
许庭洲 发表于 2012-11-25 21:39
值得学习ing!

谢谢,你是不很牛啦
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马