try {
return proc.waitFor();
} catch (InterruptedException e) {
LOG("线程等待时中断...");
e.printStackTrace();
}
return -1;
}
private
static String getProcOutput(Process proc) throws IOException, InterruptedException {
InputStream is = proc.getInputStream();
String line;
StringBuffer strResult = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
strResult.append(line);
}
is.close();
return strResult.toString().trim();
}
private
static
void LOG(String info) {
if (info != null && !info.equals("")) {
System.out.println("windows服务监控器--------" + getCurrentTime() + "----------->" + info);
}
}
private
static String getCurrentTime() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
return sdf.format(new Date()); www.2cto.com
}
// public enum ExecuteStates {
//
// SUCCEED(0, ""), STATERR_STOPPED(1, "服务已停止"), STATERR_STATED(3, "服务已开始"),
// STATERR_NOTFOUND(
// 2, "服务名无效");
//
// ExecuteStates(int code, String desc) {
// this.code = code;
// this.desc = desc;
// }
//
// private final int code;
// private final String desc;
//
// // regular get method
// public String getDesc() {
// return desc;
// }
//
// public static String getDescByCode(int code){
// for (ExecuteStates e:ExecuteStates.values()){
// if(e.code==code){
// return e.desc;
// }
// }
// return null;
// }
// }
}