ProcessBuilder does not stop

吃可爱长大的小学妹 提交于 2019-12-02 01:58:46

You need to drain both the output (via getInputStream()) and error (via getErrorStream()) streams of the process, otherwise it may block.

Quoting the Process documentation:

Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.

(which applies to both the error and output streams)

You'll probably need to drain each stream in different threads because each may block when it has no data.

It might be a lot easier for you to use a LAME Java wrapper like LAMEOnJ. That way you avoid spawning off processes and you can just interact with lame as if it were a Java library.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!