简体   繁体   English

Java Process不会退出

[英]Java Process doesn't quit

I'm trying to periodically send post requests including a pic to a site. 我正在尝试定期将包含图片的帖子请求发送到网站。 It works for the first times but then stucks. 它是第一次工作,但后来停滞了。 What am I doing wrong? 我究竟做错了什么?

p = r.exec("curl --form api_key=<key> --form api_secret=<secret> "
           + "--form upload=@record.jpg -m 20 "
           + "http://api.face.com/faces/detect.json");

BufferedReader br = 
        new BufferedReader(new InputStreamReader(p.getInputStream()));

String line = "", text = "";

while ((line = br.readLine()) != null) {
    text += line + System.getProperty("line.separator");
}

System.out.println(text);

My guess is it printing an error you cannot see. 我的猜测是打印出您看不到的错误。 (I suggest you use ProcessBuilder to redirect error messages to std out) or the process is hanging. (我建议您使用ProcessBuilder将错误消息重定向到std)或进程挂起。

Try flushing and closing the bufferedreader before doing a new request. 在执行新请求之前,请尝试刷新并关闭bufferedreader。 I never used curl, but could it be that you have to wait until the process is done before running a new one? 我从未使用过curl,但是可能是您必须等到该过程完成后才能运行新的curl吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM