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();
    		}
    	}
    

      

  • 相关阅读:
    Matlab曲面拟合和插值
    插值(scipy.interpolate)
    坐标系旋转后的点坐标、坐标点旋转后的点坐标
    halcon相机标定及图像矫正
    别再问我们用什么画图的了!问就是excalidraw
    Windows下如何玩转火热的go-zero
    我用go-zero开发了第一个线上项目
    Java基础差,需要怎么补
    2019-给你六个建议
    简说Java线程的那几个启动方式
  • 原文地址:https://www.cnblogs.com/wangxiaowang/p/7818792.html
Copyright © 2011-2022 走看看