/**
* java调用shell命令获取路径
* @return
*/
private String getHomePathName(){
Process process = null;
BufferedReader input = null;
List<String> processList = new ArrayList<String>();
try {
//linux
String[] cmdline = { "sh", "-c", "echo "+financedocumentsHomePath };
//Windows
// String[] cmdline = { "cmd.exe", "-c", "java -version"};
ProcessBuilder pb=new ProcessBuilder(cmdline);
process= pb.start();
input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = input.readLine()) != null) {
processList.add(line);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
if(input!=null){
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
String homePathName="";
if(processList!=null && processList.size()>=0){
for (String string : processList) {
homePathName+=string;
}
}
log.info("****************************财务单据报表家路径:"+homePathName+"************");
return homePathName;
}
java shell echo 环境变量
最新推荐文章于 2024-04-03 17:36:49 发布