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:/java/jdk1.6.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)