import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
// C:/Program Files (x86)/Kingsoft/WPS Office Professional/office6/wps.exe
public static void useExe() throws IOException, InterruptedException {
Process p = Runtime
.getRuntime()
.exec("java");// 调用本地方法
BufferedReader br = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String buff = null;
while ((buff = br.readLine()) != null) {
System.out.println(buff);
}
p.waitFor();
System.out.println("return code: " + p.exitValue());
}
public static void main(String[] args) {
try {
Test.useExe();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
// 21 + 15 + 23 = 59
}
}
java 打开本地程序
最新推荐文章于 2022-01-08 18:15:48 发布