简体   繁体   中英

Java - How to read output from 7z?

Hy.

I've created a routine that read .tgz files from a directory and unzip each one. I'm using

Process zip01 = Runtime.getRuntime().exec("LINE OF COMMAND");

and

exitVal = zip01.waitFor();

I,m using 7z.exe from its folder to decompress and compress files. The command line is working fine. Now, I what to read the percentage of the decompress and throw it into a textfield or a textarea. The graphics part are ok too, s well all the routine. The only dificult is to get the realtime percentage of the 7z. is there some way to read and show it?

Thanks!

You can get the output of your process like this:

Process zip01 = Runtime.getRuntime().exec("LINE OF COMMAND");

BufferedReader output = new BufferedReader(new InputStreamReader(zip01.getInputStream()));
String line;
while ((line = output.readLine()) != null) {

    /* process lines */
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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