如題,詳細看截圖:

解壓出來后,這個空檔案又不見了,請問各位大蝦:這是個什么情況?怎么解決?
PS:
有的壓縮軟體打開后是這樣,如圖:

附上代碼片段:
try {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(strZipPath));
// 需要同時下載的多個檔案
// 遍歷檔案夾,組裝檔案目錄
Set<Integer> keys = folderMap.keySet();
for (Integer key : keys) {
HashMap<String, String> valueItem = folderMap.get(key);
// 絕對路徑檔案名(格式:/ljzsg/fastdfs/file/data/00/06/wKgD91vHCPuAJdNzAAEn6ED7yKg207.jpg)
String urlPath = valueItem.get("url");
// 全路徑檔案名(格式:測驗\2\2.jpg)
String fullPathName = valueItem.get("fullPathName");
if (FileType.FILE.getValue().toString().equals(valueItem.get("type"))) {// 型別為檔案,則打包下載
if (null != urlPath && !"".equals(urlPath)
&& null != fullPathName && !"".equals(fullPathName)) {
//java.io.File f = new java.io.File(absolutePathName);
//FileInputStream fis = new FileInputStream(f);
BufferedInputStream in = dfsClient.downLoad(urlPath);
out.putNextEntry(new ZipEntry(fullPathName));
// 設定壓縮檔案內的字符編碼,不然會變成亂碼
out.setEncoding("GBK");
int len;
// 讀入需要下載的檔案的內容,打包到zip檔案
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
out.closeEntry();
in.close();
}
} else if (FileType.DEMAND_FOLDER.getValue().toString().equals(valueItem.get("type"))
|| FileType.DEMAND_REFERENCE_SUB_FOLDER.getValue().toString().equals(valueItem.get("type"))
|| FileType.INTERPOSE_REFERENCE_SUB_FOLDER.getValue().toString().equals(valueItem.get("type"))
|| FileType.VALIDATE_REFERENCE_SUB_FOLDER.getValue().toString().equals(valueItem.get("type"))
|| FileType.OTHER_FOLDER.getValue().toString().equals(valueItem.get("type"))) {// 型別為檔案夾,則打包空檔案夾
if (null != fullPathName && !"".equals(fullPathName)) {
out.putNextEntry(new ZipEntry(fullPathName + java.io.File.separator));
// 設定壓縮檔案內的字符編碼,不然會變成亂碼
out.setEncoding("GBK");
out.closeEntry();
}
}
}
out.close();
logger.info("download start");
logger.info("fileNameNoSufix=" + FileUtil.getFileNameNoEx(filename));
downloadFile(request, response, strZipPath, FileUtil.getFileNameNoEx(filename) + ".zip");
logger.info("download end");
java.io.File temp = new java.io.File(strZipPath);
if (temp.exists()) {
temp.delete();
logger.info("delete zip file.");
}
} catch (Exception e) {
logger.error(ReturnCode.ERR_DOWNLOAD_FAILED + "", e);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/133652.html
標籤:Java EE
上一篇:java操作win視窗自動化
