java读取zip文件

import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;

/**
 * 获得zip文件里的所有文件
 * @author Administrator
 *
 */
public class ZipFile {
 
 public ZipFile() throws IOException{
   java.util.zip.ZipFile zf = new java.util.zip.ZipFile("d:/a.zip");
   Enumeration e = zf.entries();
   while(e.hasMoreElements()){
      ZipEntry ze = (ZipEntry) e.nextElement();
    if(!ze.isDirectory()){
      System.out.println(new String(ze.getName().getBytes("ISO-8859-1"), "GB2312"));
    }
   }
 }
 
 public static void main(String[] args) {
  try {
      new ZipFile();
  }catch(IOException e) {
      e.printStackTrace();
  }
 }

}
 

你可能感兴趣的:(java)