Android:使用Apache Commons Compress 7zip一个文件夹 [英] Android: 7zip a folder using Apache Commons Compress

查看:611
本文介绍了Android:使用Apache Commons Compress 7zip一个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 .gradle 中包括以下内容:

compile'org.apache.commons:commons-compress :1.8'

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

我要7压缩文件夹。我已经尝试过

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.

谢谢。

推荐答案

sevenZOutput.write(contentOfEntry);

替换为

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

这篇关于Android:使用Apache Commons Compress 7zip一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆