/**
* 执行WINDOWS指令
*
* @param commend
* @return
* @throws IOException
*/
public static boolean executeCommend(String commend) throws Exception {
try {
Process process = Runtime.getRuntime().exec(commend);
process.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
throw e;
} catch (IOException e) {
// TODO Auto-generated catch block
throw e;
}
return true;
}
/**
* 执行WINDOWS指令
*
* @param commend
* @return
* @throws IOException
*/
public static boolean executeCommend(String[] commend) throws Exception {
InputStream is = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
Process process = Runtime.getRuntime().exec(commend);
is = process.getErrorStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
String message = "";
String line = "";
while ((line = br.readLine()) != null) {
message += line;
}
if (!"".equals(message)) {
log.error("调用命令行错误:" + message);
}
is.close();
isr.close();
br.close();
process.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
if (is != null) {
is.close();
}
if (isr != null) {
isr.close();
}
if (br != null) {
br.close();
}
throw e;
} catch (IOException e) {
// TODO Auto-generated catch block
if (is != null) {
is.close();
}
if (isr != null) {
isr.close();
}
if (br != null) {
br.close();
}
throw e;
}
return true;
}
* 执行WINDOWS指令
*
* @param commend
* @return
* @throws IOException
*/
public static boolean executeCommend(String commend) throws Exception {
try {
Process process = Runtime.getRuntime().exec(commend);
process.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
throw e;
} catch (IOException e) {
// TODO Auto-generated catch block
throw e;
}
return true;
}
/**
* 执行WINDOWS指令
*
* @param commend
* @return
* @throws IOException
*/
public static boolean executeCommend(String[] commend) throws Exception {
InputStream is = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
Process process = Runtime.getRuntime().exec(commend);
is = process.getErrorStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
String message = "";
String line = "";
while ((line = br.readLine()) != null) {
message += line;
}
if (!"".equals(message)) {
log.error("调用命令行错误:" + message);
}
is.close();
isr.close();
br.close();
process.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
if (is != null) {
is.close();
}
if (isr != null) {
isr.close();
}
if (br != null) {
br.close();
}
throw e;
} catch (IOException e) {
// TODO Auto-generated catch block
if (is != null) {
is.close();
}
if (isr != null) {
isr.close();
}
if (br != null) {
br.close();
}
throw e;
}
return true;
}