编写java程序调用本地文件:Runtime.getRuntime().exec(commend);
例如:
调用迅雷程序
"d:\Program Files\Thunder Network\Thunder"\thunder.exe替换commend
停止迅雷程序
taskkill /F /IM thunder5.exe /T
获取执行本地查询的数据:
Process ps = Runtime.getRuntime().exec(commend);
BufferedReader input = new BufferedReader(new InputStreamReader(ps.getInputStream()));
String line;
while((line = input.readLine()) != null){
sbuf.append(line);
sbuf.append("\n");
}
input.close();
实际程序中需要使用try/catch语句获取异常
例如:
调用迅雷程序
"d:\Program Files\Thunder Network\Thunder"\thunder.exe替换commend
停止迅雷程序
taskkill /F /IM thunder5.exe /T
获取执行本地查询的数据:
Process ps = Runtime.getRuntime().exec(commend);
BufferedReader input = new BufferedReader(new InputStreamReader(ps.getInputStream()));
String line;
while((line = input.readLine()) != null){
sbuf.append(line);
sbuf.append("\n");
}
input.close();
实际程序中需要使用try/catch语句获取异常