700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Java实现zip解压缩目录中的所有文件

Java实现zip解压缩目录中的所有文件

时间:2019-05-04 22:28:11

相关推荐

Java实现zip解压缩目录中的所有文件

Java|java教程

代码片段,代码分享,PHP代码分享,Java代码分享,Ruby代码分享,Python代码分享,HTML代码分享,CSS代

Java-java教程

php彩票走势图源码,ubuntu定制cubic,tomcat7启用失败,python爬虫标题,php游戏开发和平台对接,seo站长必备十大工具lzw

import java.io.*;import java.util.*;import java.util.zip.*;public class FolderUnzip {private static String sourcepath="D:\\tmp";private static ListfolderList=new ArrayList(Arrays.asList(sourcepath));private static ListfolderList2=new ArrayList(Arrays.asList("E:\\tt"+File.separator+sourcepath.substring(sourcepath.lastIndexOf(File.separator))));private static FileInputStream fis = null;private static FileOutputStream fos = null;private static ZipInputStream zipin = null; public static void main(String[] args) { for (int j = 0; j < folderList.size(); j++) { new File(folderList2.get(j)).mkdirs(); String[] file = new File(folderList.get(j)).list(); File temp = null; for (int i = 0; i < file.length; i++) {if (folderList.get(j).endsWith(File.separator)) temp = new File(folderList.get(j), file[i]);else temp = new File(folderList.get(j), file[i]);File originalFile = null;if (temp.getName().endsWith(".zip")) originalFile = new File(folderList2.get(j), temp.getName() .substring(0, temp.getName().lastIndexOf(.)));if (temp.isFile() && !originalFile.exists()) { try { fis = new FileInputStream(temp); zipin = new ZipInputStream(fis); ZipEntry entry = zipin.getNextEntry(); fos = new FileOutputStream(new File(folderList2.get(j),entry.getName())); byte[] buffer = new byte[20480]; int nNumber; while ((nNumber = zipin.read(buffer, 0, buffer.length)) != -1) fos.write(buffer, 0, nNumber); fos.flush(); } catch (IOException e) { continue; } finally { try { zipin.close(); fos.close(); fis.close(); } catch (IOException e) { } }} else if (temp.isDirectory()) { folderList.add(folderList.get(j) + File.separator + file[i]); folderList2.add(folderList2.get(j) + File.separator+ file[i]);} } } }}

ssdp源码,固态盘ubuntu分区,xpath爬虫获取链接,php ~符号,华为招seolzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。