Java process - unable to unzip zip file

后端 未结 2 1945
梦毁少年i
梦毁少年i 2021-01-28 21:07

I am trying to unzip some zip file, it has about 65 megs. Code snippets below:

This method actually unzips a file:

public synchronized void execute(Path          


        
2条回答
  •  清歌不尽
    2021-01-28 21:27

    The unzip command prints the details of the files it is unzipping to its standard output, so you need to read this in your Java program (via Process.getInputStream). If you don't read the output in a timely fashion the process may block once its buffer gets full - this is spelled out in the javadoc of Process.

    I recommend you call builder.redirectErrorStream(true) and then ensure you read all the data from the process stream. You may also benefit from adding a -qq argument to the unzip call, to minimise the amount of output it creates in the first place.

提交回复
热议问题