62,623
社区成员
发帖
与我相关
我的任务
分享import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
public class ZipTest {
public static void main(String[] args) throws IOException {
ZipFile zip= new ZipFile(new File("e:/log.zip"));
Enumeration e = zip.getEntries(); // java包是zip.entries();
while(e.hasMoreElements()) {
ZipEntry entry = (ZipEntry)e.nextElement();
BufferedReader br = new BufferedReader(new InputStreamReader(zip.getInputStream(entry)));
String str = null;
System.out.println("----------------------------");
System.out.println(entry.getName());
System.out.println("----------------------------");
while( (str = br.readLine())!=null ) {
System.out.println(str);
}
br.close();
}
zip.close();
}
}