使用ProcessBuilder修复损坏的zip文件

时间:2019-07-04 05:31:07

标签: java zip corrupt

当我在Mac终端中执行“ zip -FF /Users/myZip.zip?--out Users / myFixed.zip”时,损坏的zip文件已修复。 当我尝试修复以下相同的损坏的zip文件时,出现以下错误。

请分享您的意见以解决此问题。

代码:

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

错误消息:

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)

1 个答案:

答案 0 :(得分:0)

每个参数应为不同的字符串

例如

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