⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outzipfiletest.java

📁 java实现简单的压缩和解压缩程序!大家可以看看
💻 JAVA
字号:
package com.bling.zip;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class OutZipFileTest {
	
	private ZipFile zip = null;
	private Enumeration enu = null;
	private ZipEntry  entry = null;
	private String fileName = null;
	
	private InputStream in = null;
	private FileOutputStream fout = null;
	private byte[] b = new byte[1024];
	private int len = 0;
	
	
	public OutZipFileTest(String inFileName) {
		try {
			zip = new ZipFile(inFileName);
			enu = zip.entries();
			while (enu.hasMoreElements()){
				entry = (ZipEntry)enu.nextElement();
				fileName = entry.getName();
				in = zip.getInputStream(entry);
				fout = new FileOutputStream(fileName);
				while ((len = in.read(b)) > 0){
					fout.write(b, 0, len);
				}
				in.close();
				fout.close();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		String inFileName ="test.zip";
		new OutZipFileTest(inFileName);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -