zoukankan      html  css  js  c++  java
  • zip包的解压

    public static void unzip1(String zipName, String temPath) throws IOException {
    		ZipFile zip = new ZipFile(new File(zipName),Charset.forName("UTF-8"));
    		String zipName1 = zip.getName().substring(zip.getName().lastIndexOf("\") + 1, zip.getName().lastIndexOf("."));
    		System.out.println(zipName1);
    		String temp = temPath + "/" + zipName1 + System.currentTimeMillis();
    		File filePath = new File(temp);
    		if (!filePath.exists()) {
    			filePath.mkdirs();
    		}
    		
    		for (Enumeration<ZipEntry> zipEntrys = (Enumeration<ZipEntry>) zip.entries(); zipEntrys.hasMoreElements();) {
    			ZipEntry entry = zipEntrys.nextElement();
    			String name = entry.getName();
    			 System.out.println(name);
    			InputStream is = zip.getInputStream(entry);
    			String outputPath = (temp + "/" + name).replaceAll("\*", "/");
    			//判断文件路径是否存在
    			File file = new File(outputPath.substring(0, outputPath.lastIndexOf("/")));
    			if (!file.exists()) {
    				file.mkdirs();
    			}
    			
    			if (new File(outputPath).isDirectory()) {
    				continue;
    			}
    			
    			FileOutputStream os = new FileOutputStream(outputPath);
    			byte[] buf = new byte[1024]; 
    			int len = 0;
    			while((len = is.read(buf)) != -1) {
    				os.write(buf, 0, len);
    			}
    			os.close();
    			is.close();
    		}
    		System.out.println("解压成功。。。。");
    	}
    	
    	public static void main(String[] args) {
    		String dir = "E:/test";
    		String zipName = "E:/test/zhangsan.zip";
    		String tempPath = "E:/zip";
    //		unzip(dir, zipName, tempPath);
    		File file = new File(zipName);
    		try {
    //			unZipFiles(file, tempPath);
    			
    //			unzip1(zipName, tempPath);
    			System.out.println(invertOrder(123569));
    		} catch (Exception e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    	}
    

      

  • 相关阅读:
    阻塞赋值和非阻塞赋值
    组合逻辑和时序逻辑
    信道估计常用算法
    Verilog有限状态机FSM
    希尔伯特变换
    微信小程序取消分享的两种方式
    orm 常用字段
    drf获取请求过来时的request
    WeChat--API
    Django之admin源码浅析
  • 原文地址:https://www.cnblogs.com/wangxiaowang/p/7818792.html
Copyright © 2011-2022 走看看