0

皆さん、

zip4j APIを使用してJavaで.zipファイルを抽出しており、ファイルを抽出できます

  1. 完全なディレクトリを圧縮してzipを作成するために使用しました。これには、ファイルとネストされたディレクトリが含まれています。

    zipFile.addFolder(fileDirectory, parameters);//ZIP ディレクトリ ファイル/フォルダ

  2. を使用してzipを抽出する

    ZipFile zipFile = new ZipFile(stringArchievedFile);
    //Extracts all files to the path specified
    zipFile.extractAll(stringExtractingFilePath);
    

問題は抽出後です。ファイルはzipFile.extractAll(path)メソッドで指定したパスに抽出する必要がありますが、もう1つのディレクトリが作成されています。実際に指定されたディレクトリにファイルを抽出するにはどうすればよいですか

同様に: 抽出パス C:\ExtractionPath

ファイル パス C:\SelectingPath\File1

C:\SelectingPath\File2

C:\SelectingPath\Directory1\File1

C:\SelectingPath\Directory2\File1

C:\SelectingPathディレクトリを選択して zip し、

C:\ExtractionPathディレクトリを選択してファイルを抽出します

抽出後、抽出されたすべてのファイルは

**C:\ExtractionPath\SelectingPath**

ディレクトリ内のすべてのファイルが必要です

**C:\ExtractionPath** 自体。

この問題を解決するために私を助けてください。

前もって感謝します

4

2 に答える 2

1

次のようなZip4j サイトの例を試してみません か :

/*
* Copyright 2010 Srikanth Reddy Lingala  
* 
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
* http://www.apache.org/licenses/LICENSE-2.0 
* 
* Unless required by applicable law or agreed to in writing, 
* software distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License. 
*/

package net.lingala.zip4j.examples.extract;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;

/**
 * Demonstrates extracting all files from a zip file
 * 
 * @author Srikanth Reddy Lingala
 *
 */
public class ExtractAllFiles {

    public ExtractAllFiles() {

        try {
            // Initiate ZipFile object with the path/name of the zip file.
            ZipFile zipFile = new ZipFile("c:\\ZipTest\\ExtractAllFiles.zip");

            // Extracts all files to the path specified
            zipFile.extractAll("c:\\ZipTest");

        } catch (ZipException e) {
            e.printStackTrace();
        }

    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        new ExtractAllFiles();
    }

}
于 2016-09-24T08:50:38.290 に答える