找回密码
 立即注册
catchpathprintStackTraceFiles | Applet 2022-10-09 61 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
java8、lambda、stream使用publicclassZip_uncompressimplementsUncompressInterface{publicvoiduncompress(StringcompressFile,StringoutDir){try{ZipFilezf=newZipFile(compressFile);Enumerationlt;ZipEntrygt;enu=zf.getEntries();Listlt;ZipEntrygt;list=newArrayList();while(enu.hasMoreElements()){list.add(enu.nextElement());}list.forEach(p-gt;{try{java.nio.file.FileSystemfs=FileSystems.getDefault();intss=p.getName().lastIndexOf(\/\)+1;Stringpp=p.getName().substring(ss);nbsp<imgsrc="titter.gif"smilieid="9"border="0"alt=""/>athpath=Paths.get(outDir+pp);System.out.println(\ZipFile:\+ss+path);if(!p.isDirectory()){if(!Files.exists(path.getParent()))Files.createDirectories(path.getParent());Files.copy(zf.getInputStream(p),path,StandardCopyOption.REPLACE_EXISTING);}}catch(Exceptione){catch{e.printStackTrace();}});}catch(IOExceptione){//TODO自动生成的catch块e.printStackTrace();}}

(Java8, lambda and stream use publicclassZip_ uncompressimplementsUncompressInterface{publicvoiduncompress(StringcompressFile,StringoutDir){try{ZipFilezf=newZipFile(compressFile);Enumerationlt;ZipEntrygt;enu=zf.getEntries();Listlt;ZipEntrygt;list=newArrayList();while(enu.hasMoreElements()){list.add(enu.nextElement());} list.forEach(p-gt;{try{java.nio.file.FileSystemfs=FileSystems.getDefault();intss=p.getName().lastIndexOf(\/\) 1;Stringpp=p.getName().substring(ss);nbsp<imgsrc="titter.gif"smilieid="9"border="0"alt=""/>athpath=Paths.get(outDir pp);System.out.println(\ZipFile:\ ss path);if(!p.isDirectory()){if(!Files.exists(path.getParent()))Files.createDirectories(path.getParent());Files.copy(zf.getInputStream(p) ,path,StandardCopyOption.REPLACE_ EXISTING);}} catch(Exceptione){catch{e.printStackTrace();}});} Catch (IOExceptione) {//catch block e.printStackTrace();}} automatically generated by TODO)

[下载]12230048341.rar




上一篇:2138imageupload
下一篇:Struts2+Hibernate开发需要用到的一些jar包