小编nay*_*kam的帖子

如何在不改变原始文件的情况下解压*.TGZ文件?

可能的重复:
你如何用枪压缩文件并保留 .gz 文件?

我使用以下命令解压缩文件:

gunzip -f  test.TGZ
Run Code Online (Sandbox Code Playgroud)

这给了我 test.tar 文件,但我丢失了 test.TGZ 文件。有没有办法保留原始文件?

编辑和更新:我通过 Java 程序调用解压缩命令。TGZ 文件至少包含 1 个图像文件、1 个文本文件和 1 个视频文件。

Java方法:执行命令

private static InputStream executeCommand(String command, File workingDir)
        throws Exception {
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(command, null, workingDir);
    int exitValue = -1;
    try {
        exitValue = process.waitFor();
    } catch (InterruptedException ignore) {
    }

    if (exitValue != 0) {
        InputStream errStream = process.getErrorStream();
        String errMessage = null;
        if (errStream.available() > 0) {
            byte[] errOutput = new …
Run Code Online (Sandbox Code Playgroud)

unix zip java gzip gunzip

1
推荐指数
1
解决办法
4571
查看次数

标签 统计

gunzip ×1

gzip ×1

java ×1

unix ×1

zip ×1