简体   繁体   中英

Execute winzip command in a java program

Need to execute the below winzip command in a java program.

C:\Program Files\WinZip>winzip32 -a -s"password" C:\abc.zip C:\abc.doc

Use Runtime#exec() ( tutorial here , caveats here ) or just pure Java code ( related SO topic ).

By the way, if you didn't need password protection, you could just go ahead with java.util.zip ( tutorial here ).

You can simple use Runtime.exec() ;

String[] cmd = {"C:\\Program Files\\WinZip\\winzip32", "-a", "-s", "password", "C:\\abc.zip", "C:\\abc.doc"};
Runtime.getRuntime().exec(cmd);

Taking a look around the internet, would this do what you're looking for: https://truezip.dev.java.net/ without having to rely on an external install of WinZip which may or may not exist on the end user system? Just a suggestion.

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