package sy.ui;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) {
excuteCommand("ipconfig");
excuteCommand("ping 10.141.26.50");
//可以执行.EXE 等等文件
String path = "d:\\Program Files\\多玩英雄联盟盒子\\LOLBox.exe";
excuteCommand("rundll32 url.dll FileProtocolHandler " + path);
}
public static void excuteCommand(String command) {
Runtime r = Runtime.getRuntime();
Process p;
try {
p = r.exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String inline;
while ((inline = br.readLine()) != null) {
System.out.println(inline);
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
java 调用本地应用程序
最新推荐文章于 2024-03-18 11:24:17 发布