linux命令call linux命令行快捷键( 六 )


InputStreamReader isr = new InputStreamReader(is);
// 用缓冲器读行
BufferedReader br = new BufferedReader(isr);
String line = null;
StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null) {
System.out.println(line);
sb.append(line);
}
is.close();
isr.close();
br.close();
return sb.toString();
} catch (java.lang.NullPointerException e) {
System.err.println("NullPointerException " + e.getMessage());
logger.error(cmd);
} catch (java.io.IOException e) {
System.err.println("IOException " + e.getMessage());
}
throw new ExecuteException(cmd + "执行出错!");
}
if(SystemUtils.IS_OS_WINDOWS){
Process process;
try {
//process = new ProcessBuilder(cmd).start();
String[] param_array = cmd.split("[\\s]+");
ProcessBuilder pb = new ProcessBuilder(param_array);
process = pb.start();
/*process=Runtime.getRuntime().exec(cmd);*/
int exitCode = process.waitFor();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null) {
System.out.println(line);
sb.append(line);
}
is.close();
isr.close();
br.close();
return sb.toString();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
throw new ExecuteException(cmd + "执行出错!");
}
throw new UnHandledOSException("不支持本操作系统");
}
【linux命令call linux命令行快捷键】关于linux命令call和linux命令行快捷键的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读