java調用機器上的shell腳本

java調用機器上的shell腳本,能夠這樣方便的經過shell腳本調用本機的C、C++等程序java

Process process = null;
Runtime runTime = Runtime.getRuntime();
String shellCmd = "sh xxxxxxxxxxx.sh ";
String shellPath = getSoLibPath();
logger.info("執行shell命令:" + shellCmd);
long startTime = System.currentTimeMillis();
process = runTime.exec(shellCmd, null, new File(shellPath));
int resultCode = process.waitFor();
long endTime = System.currentTimeMillis();
logger.info("耗時=" + (endTime - startTime) + "毫秒");
相關文章
相關標籤/搜索