我想使用7zip展开一个zip文件,但我不断收到7zip使用情况打印输出。使用7zip展开文件
拉链存在于C:\ TEMP
同样的命令在批处理窗口成功:
C:\TEMP>7z x "tryThis.zip"
我尝试添加工作目录的文件路径,也没有工作目录, 什么帮帮我。 - 我可以运行CMD/c命令,但我更愿意保持代码清洁
我在做什么错了?
谢谢!
String pathTo7ZipExe = "c:\\program files\\7-zip\\7z.exe";
String fileName ="tryThis.zip";
String workingDir = "c:\\temp\\";
Process process = Runtime.getRuntime().exec(
new String[]{pathTo7ZipExe},
new String[]{" x \"" + fileName +"\""},
new File(workingDir));
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
// wait for zip to end.
int exitVal = process.waitFor();
谢谢!这一个为我工作。 – user648026 2013-02-15 22:23:40
太棒了! - btw [this](http://www.kodejava.org/examples/334.html)将是java的ZipInputStream解决方案。一个优点是,您可以专门查找元素,而无需拆开整个存档。 – 2013-02-15 22:25:39