Runtime.getRuntime().exec(“文件的位置”)
try {
Runtime.getRuntime().exec("文件名");
} catch (IOException e) {
e.printStackTrace();
}
脚本
String res = "";
List<String> processList = new ArrayList<String>();
try {
Process process = Runtime.getRuntime().exec("/home/java/jar/restart12347.sh");
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = input.readLine()) != null) {
processList.add(line);
}
input.close();
} catch (IOException e) {
e.printStackTrace();
}
for (String line : processList) {
System.out.println(line);
res = res + line;
}
特殊说明:
以上文章,均是我实际操作,写出来的笔记资料,不会盗用别人文章!烦请各位,请勿直接盗用!转载记得标注来源!