Java如何运行Unix或Linux脚本

走着路睡觉
  • java
小于 1 分钟


java.lang.ProcessBuilder pb = new java.lang.ProcessBuilder("myshellScript.sh", "myArg1", "myArg2");
 Map<String, String> env = pb.environment();
 env.put("VAR1", "myValue");
 env.remove("OTHERVAR");
 env.put("VAR2", env.get("VAR1") + "suffix");
 pb.directory(new File("myDir"));
 Process p = pb.start();
上次编辑于:
贡献者: zhaojingbo
Loading...