我正在尝试使用Process Builder将数据下载到文件中:
ProcessBuilder pb = new ProcessBuilder(
"curl",
"--negotiate",
"-u" ,":" ,"-b", "~/cookiejar.txt", "-c", "~/cookiejar.txt",
"http:*****509-0500/mobile*****.snappy?op=open | snzip -d"
);
Process p;
try
{
pb.redirectOutput(new File("~/testTest.txt"));
p = pb.start();
p.waitFor();//added based on Earlybird's suggestion
}
catch (IOException e)
{ System.out.print("error");
e.printStackTrace();
}
这里创建了文件testTest.txt,但文件中没有出现任何内容(尝试阻止成功)。 cURL命令在终端上正常工作。