-->

Android: 7zip a folder using Apache Commons Compre

2019-08-13 19:25发布

问题:

I have included the following in my .gradle:
compile 'org.apache.commons:commons-compress:1.8'

I want to 7zip a folder. I have tried

SevenZOutputFile sevenZOutput = new SevenZOutputFile(file);
SevenZArchiveEntry entry = sevenZOutput.createArchiveEntry(fileToArchive, name);
sevenZOutput.putArchiveEntry(entry);
sevenZOutput.write(contentOfEntry); //this is what I don't understand!!
sevenZOutput.closeArchiveEntry();

I require some help and assistance in accomplishing the above task.

Thanks.

回答1:

sevenZOutput.write(contentOfEntry);

replace to

sevenZOutput.write(Files.toByteArray(fileToArchive));