简体   繁体   English

使用ProcessBuilder修复损坏的zip文件

[英]Fixing broken zip file by using ProcessBuilder

When i execute "zip -FF /Users/myZip.zip? --out Users/myFixed.zip" in my Mac terminal,the broken zip file is fixed. 当我在Mac终端中执行“ zip -FF /Users/myZip.zip?--out Users / myFixed.zip”时,损坏的zip文件已修复。 When i try to fix the same broken zip file as below it gives me the following error. 当我尝试修复以下相同的损坏的zip文件时,出现以下错误。

Please share your opinions to fix this issue. 请分享您的意见以解决此问题。

The Code: 编码:

ProcessBuilder pb1 = new ProcessBuilder("bash", "-c", "zip -FF/Users/myZip.zip 
   --out /Users/myFixed.zip");
   pb1.redirectErrorStream(true);
   Process p =pb1.start();

The Error Message: 错误消息:

1 Fix archive (-FF) - salvage what can
2   zip warning: could not open input archive: /Users/myZip.zip
3 Scanning for entries... 
4  Could not find: /Users/myZip.z01
5
6 
7 Hit c      (change path to where this split file is)
8     s      (skip this split)
9     q      (abort archive - quit)
10    e      (end this archive - no more splits)
11    z      (look for .zip split - the last split)

Each argument should be a different String 每个参数应为不同的字符串

eg 例如

ProcessBuilder pb1 = new ProcessBuilder("bash", "-c", "zip", "-FF", "/Users/myZip.zip", 
   "--out", "/Users/myFixed.zip");

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

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