读取压缩文件下多级目录的文件(按行读取)
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import org.apache.tools.zip.ZipEntry; import org.apache.tools.zip.ZipFile; public class ZipUtil { /** * 读取压缩文件下多级目录的文件(按行读取) * @author zhengqiang */ public List<String> printZipTxt(String zipPath) throws IOException{ List<String> list = new ArrayList<String>(); ZipFile zipFile=new ZipFile(zipPath); for (Enumeration<? extends ZipEntry> e = zipFile.getEntries(); e.hasMoreElements();){ ZipEntry entry=e.nextElement(); if(!entry.isDirectory()){ BufferedReader br=new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry))); String line = ""; while((line = br.readLine()) != null){ if(line.length() > 0){ list.add(line); } } br.close(); } } return list; } }