private static void exec() throws IOException, InterruptedException {
String command = "curl -X GET \"http://localhost:8333/api/msg/list?xh=" + index++ + "&pageNo=30&pageSize=2&beginTime=2020-09-07%2000:00:00&endTime=2021-09-07%2023:59:59&keyword=&suid=&uid=\" -H \"tenantId:1\" -H \"Authorization:\" -H \"Request-Origion:SwaggerBootstrapUi\" -H \"accept:application/json\"\n";
Process process = Runtime.getRuntime().exec(command);
BufferedInputStream bis = new BufferedInputStream(
process.getInputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(bis));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
process.waitFor();
if (process.exitValue() != 0) {
System.out.println("error!");
}
bis.close();
br.close();
}
java执行外部命令
最新推荐文章于 2022-11-02 22:11:35 发布