91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.77MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-08-16
  • 語言: Java
  • 標簽: java??解壓縮??7z??

資源簡介

該文件為java版的7z解壓縮工具,目前已經支持tar,7z,gz等格式的代碼解壓縮

資源截圖

代碼片段和文件信息

package?com.yozo.zip;

import?java.io.BufferedOutputStream;
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.InputStream;
import?java.io.OutputStream;

import?org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
import?org.apache.commons.compress.archivers.sevenz.SevenZFile;
import?org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import?org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import?org.apache.commons.compress.compressors.CompressorInputStream;
import?org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import?org.apache.commons.compress.utils.IOUtils;

/**
?*?解壓?tar?7z?gz?格式的壓縮包文件
?*?@author?許玉康
?*
?*/

public?class?Tar7zGzUtils?{

/**
?*?解壓tar文件
?*?
?*?@param?orgPath
?*?@param?tarpath
?*?@return
?*?@throws?Exception?
?*/
public?Boolean?extTarFileList(String?orgPath?String?tarpath)?{
Boolean?result?=?false;
createFile(tarpath);
TarArchiveInputStream?tais?=?null;
try?{
File?srcFile?=?new?File(orgPath);
tais?=?new?TarArchiveInputStream(new?FileInputStream(srcFile));
TarArchiveEntry?entry?=?null;
????????while?((entry?=?tais.getNextTarEntry())?!=?null)?{
????????????//?文件
????????????String?dir?=?tarpath?+?entry.getName();
????????????File?dirFile?=?new?File(dir);
????????????//?文件檢查
????????????fileProber(dirFile);
????????????if?(entry.isDirectory())?{
????????????????dirFile.mkdirs();
????????????}?else?{
????????????????dearchiveFile(dirFile?tais);
????????????}
????????}
????????result?=?true;
}?catch?(Exception?e)?{
e.printStackTrace();
}finally?{
try?{
????????????????if(tais?!=?null){
???????????????? tais.close();
????????????????}
????????????}?catch?(IOException?e)?{}
}
return?result;
}

/**
?*?創建文件
?*/
private?void?createFile(String?filePath)?{
File?dFile?=?new?File(filePath);
if?(!dFile.exists())?{
dFile.mkdirs();
}
}

/**?
?????*?文件解歸檔?(輸出到目標文件中)
?????*/??
????private?void?dearchiveFile(File?destFile?TarArchiveInputStream?tais)?{
???? BufferedOutputStream?bos?=?null;
???? try?{
???? bos?=?new?BufferedOutputStream(new?FileOutputStream(destFile));
????????????int?count;
????????????byte?data[]?=?new?byte[1024];
????????????while?((count?=?tais.read(data?0?1024))?!=?-1)?{
???????????? bos.write(data?0?count);
????????????}
}?catch?(Exception?e)?{
e.printStackTrace();
}finally?{
try?{
if(bos?!=?null)?{
bos.close();
}
}?catch?(Exception?e2)?{
e2.printStackTrace();
}
}
????}

/**?
?????*?文件探針?
?????*/??
????private?void?fileProber(File?dirFile)?{??
????????File?parentFile?=?dirFile.getParentFile();??
????????if?(!parentFile.exists())?{
????????????//?遞歸尋找上級目錄??
????????????fileProber(parentFile);??
????????????parentFile.mkdir();??
????????}
????}


//7z格式解壓
public

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????1438086??2018-07-05?09:49??7z1805-x64.exe
?????文件??????378217??2018-07-05?11:11??commons-compress-1.9.jar
?????文件????????6286??2018-07-06?14:00??Tar7zGzUtils.java
?????文件???????99555??2018-07-05?11:13??xz-1.5.jar

評論

共有 條評論