| | |
| | | ZipInputStream zipInputStream = null; |
| | | try{ |
| | | FileInputStream inputStream = new FileInputStream(zipFileName); |
| | | zipInputStream = new ZipInputStream(new BufferedInputStream(inputStream), StandardCharsets.ISO_8859_1); |
| | | zipInputStream = new ZipInputStream(new BufferedInputStream(inputStream), Charset.forName("GBK")); |
| | | java.util.zip.ZipEntry ze; |
| | | List<FileMessage> list = new ArrayList<>(); |
| | | //循环遍历 |
| | |
| | | ZipFile zip = new ZipFile(zipFile, Charset.forName("GBK")); |
| | | for(Enumeration entries = zip.entries(); entries.hasMoreElements();){ |
| | | ZipEntry entry = (ZipEntry)entries.nextElement(); |
| | | InputStream in = zip.getInputStream(entry); |
| | | //输出文件路径信息 |
| | | FileMessage fileMessage=new FileMessage(); |
| | | fileMessage.setFileName(entry.getName()); |
| | | fileMessage.setFileSize(entry.getSize()); |
| | | String formatted = ActionUtil.sdfwithALL.format( new Date( entry.getLastModifiedTime().toMillis() ) ); |
| | | fileMessage.setFileTime(formatted); |
| | | list.add(fileMessage); |
| | | in.close(); |
| | | if (!entry.isDirectory()) { |
| | | InputStream in = zip.getInputStream(entry); |
| | | //输出文件路径信息 |
| | | FileMessage fileMessage = new FileMessage(); |
| | | fileMessage.setFileName(entry.getName()); |
| | | fileMessage.setFileSize(entry.getSize()); |
| | | String formatted = ActionUtil.sdfwithALL.format(new Date(entry.getLastModifiedTime().toMillis())); |
| | | fileMessage.setFileTime(formatted); |
| | | list.add(fileMessage); |
| | | in.close(); |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |