/**
* 解压
* @param fileUtils 文件对象
* @param srcF 源文件
* @param dir 目录
* @see Expand#expandFile(FileUtils, File, File)
* @throws IOException 抛出IO异常
*/
protected void expandFile(FileUtils fileUtils, File srcF, File dir)
throws IOException
{
FileInputStream fis = null;
TarInputStream tis = null;
try
{
fis = new FileInputStream(srcF);
tis = new TarInputStream(compression.decompress(srcF,
new BufferedInputStream(fis)));
TarEntry te = null;
while ((te = tis.getNextEntry()) != null)
{
extractFile(fileUtils,
srcF,
dir,
tis,
te.getName(),
te.getModTime(),
te.isDirectory());
}
}
finally
{
if (tis != null)
{
tis.close();
}
if (fis != null)
{
fis.close();
}
}
}
解压tar包工具UntarUtil(2)
最新推荐文章于 2024-09-04 21:56:48 发布
本文详细介绍了使用Java进行文件解压缩的过程,包括如何利用TarInputStream读取并处理压缩文件中的每一项内容,确保所有文件都能正确地从源压缩包中提取到指定的目标目录下。
360

被折叠的 条评论
为什么被折叠?



