ZIP压缩文件问题

不同系统使用ZipEntry压缩文件出现中文编码问题(本地Windows没有问题发布到Linux服务器出现此问题)

 

 

 

 

 替换为org.apache.commons.compress包下的ZipArchiveEntry即可解决

         <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
            <version>1.8.1</version>
        </dependency> 

 

                ZipArchiveEntry  ze = null;
                        MultipartFile mfile = null;
                        zis = new ZipArchiveInputStream(file.getInputStream());
                        String zipFileName = null;
                        ByteArrayOutputStream byteArrayOutputStream = null;
                        while (((ze = zis.getNextZipEntry()) != null)) {
                            byteArrayOutputStream = new ByteArrayOutputStream();
                            zipFileName = ze.getName();
                            if(ze.isDirectory()){
                                continue;
                            }
                            if(zipFileName.lastIndexOf("/") != -1){
                                zipFileName = zipFileName.substring(zipFileName.lastIndexOf("/")+1);
                            }
              }        
posted @ 2020-09-16 16:48  Gowell  阅读(195)  评论(0)    收藏  举报