亚洲精品一区二区手机在线观看,久久久久久夜,国产精品人人爽97欧美视频,超碰人人婷婷,国产剧免费观看高清电视剧,99av亚洲综合一区二区,91精品欧美久久久久,久久婷婷五月综合色D啪

ZIP文件壓縮

時間:2023-05-17

在開發過程中遇到一個小需求,將附件中的文件停止緊縮,緊縮文件以前沒怎樣接觸過,記載下,直接上代碼:
/***
*將附件中的文件緊縮
*
*@paramfileMap
緊縮前的文件
*@returnMap<String,byte[]>
緊縮后的文件java
*/
privateMap<String,byte[]>filesCompressionZIP(Map<String,byte[]>fileMap){
Map<String,byte[]>map=newHashMap();
ByteArrayOutputStreambos=newByteArrayOutputStream();
ZipOutputStreamzip=newZipOutputStream(bos);
try{
ZipEntryentry=null;
for(Map.Entry<String,byte[]>en:fileMap.entrySet()){
entry=newZipEntry(en.getKey());
entry.setSize(en.getValue().length);
zip.putNextEntry(entry);
zip.write(en.getValue());
}
}catch(Excepritone){
LOGGER.error(e.getMessage(),e);
}finally{
try{
zip.closeEntry();
}catch(IOExcepritone){
LOGGER.error(e.getMessage(),e);
}
try{
zip.close();
}catch(IOExcepritone){
LOGGER.error(e.getMessage(),e);
}
try{
bos.close();
}catch(IOExcepritone){
LOGGER.error(e.getMessage(),e);
}
}
map.put(System.currentTimeMillis()+”.zip”,bos.toByteArray());
returnmap;
}
看代碼表現你的價值

文章標簽:

Copyright ? 2016 廣州思洋文化傳播有限公司,保留所有權利。 粵ICP備09033321號

與項目經理交流
掃描二維碼
與項目經理交流
掃描二維碼
與項目經理交流
ciya68