如何拉链和解压缩文件?
如何将所有已在DDMS中已经存在的文件进行邮政和解压缩:data/data/mypackage/files/
我需要一个简单的示例。我已经搜索了ZIP和UNZIP。但是,我没有一个例子。任何人都可以说明一些例子。进步谢谢。
How to zip and unzip the files which are all already in DDMS : data/data/mypackage/files/
I need a simple example for that. I've already search related to zip and unzip. But, no one example available for me. Can anyone tell some example. Advance Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看 zip 功能的 java.util.zip.* 类。我已经完成了一些基本的压缩/解压缩代码,并将其粘贴在下面。希望有帮助。
Take a look at java.util.zip.* classes for zip functionality. I've done some basic zip/unzip code, which I've pasted below. Hope it helps.
ZIP函数Brianestey提供了很好的功能,但是由于一次读取一个字节,UNZIP函数非常慢。这是他的Unzip功能的修改版本,它使用缓冲区,并且更快。
The zip function brianestey provided works well, but the unzip function is very slow due to reading one byte at a time. Here is a modified version of his unzip function that utilizes a buffer and is much faster.
这个答案基于 brianestey、Ben、Giacomo Mattiuzzi、Joshua Pinter。
函数重写为 Kotlin,并添加了使用 Uri 的函数。
This answer is based of brianestey, Ben, Giacomo Mattiuzzi, Joshua Pinter.
Functions rewritten to Kotlin and added functions for working with Uri.
使用
File
代替文件路径String
。这个答案基于@brianestey 的优秀答案。
我修改了他的 zip 方法以接受文件列表而不是文件路径和输出 zip 文件而不是文件路径,这可能对其他人有帮助,如果这就是他们正在处理的内容。
Using
File
instead of the file pathString
.This answer is based off of @brianestey's excellent answer.
I have modified his
zip
method to accept a list of Files instead of file paths and an output zip File instead of a filepath, which might be helpful to others if that's what they're dealing with.