ZipEntry归档 [英] ZipEntry to File
本文介绍了ZipEntry归档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有直接方法将 java.util.zip.ZipEntry
解压缩为 File
?
Is there a direct way to unpack a java.util.zip.ZipEntry
to a File
?
我想指定一个位置(例如"C:\ temp \ myfile.java"),然后将条目解压缩到该位置.
I want to specify a location (like "C:\temp\myfile.java") and unpack the Entry to that location.
网络上有一些带有流的代码,但我希望使用经过测试的库函数.
There is some code with streams on the net, but I would prefer a tested library function.
推荐答案
使用ZipFile类
ZipFile zf = new ZipFile("zipfile");
获取条目
ZipEntry e = zf.getEntry("name");
获取大量信息
InputStream is = zf.getInputStream(e);
保存字节
Files.copy(is, Paths.get("C:\\temp\\myfile.java"));
这篇关于ZipEntry归档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文