I'm getting a problem with apache commons compress

I'm getting this error while extracting a .7z protected file

org.tukaani.xz.CorruptedInputException: Compressed data is corrupt

and I'm using this code

public static void unSevenZipFile(String from,String to,String pass) throws Exception
{
    // Get 7zip file.
    SevenZFile sevenZFile = new SevenZFile(new File(from),pass.getBytes("UTF16LE"));

    SevenZArchiveEntry entry;
    while ((entry = sevenZFile.getNextEntry()) != null)
    {

        File file = new File(to + entry.getName());
        Log.d("unzip","Un seven zipping - " + file);
        // Create directory before streaming files.
        String dir = file.toPath().toString().substring(0, file.toPath().toString().lastIndexOf("/"));
        Files.createDirectories(new File(dir).toPath());
        // Stream file content
        byte[] content = new byte[(int) entry.getSize()];
        sevenZFile.read(content);
        Files.write(file.toPath(), content);
        
    }


}

if You know what's the problem please tell me. Thanks in advance

Upvotes: 0

Views: 545

Answers (1)

The problem was I didn't place the dash in the right place. I did both this "UTF16LE" and "UTF-16LE" but the solution was this "UTF16-LE"

Upvotes: 1

Related Questions