Read entries in a zip / compressed file
import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class Main { public static void main(String[] args) throws Exception { ZipFile zip = new ZipFile(new File("sample.zip")); for (Enumeration e = zip.entries(); e.hasMoreElements();) { ZipEntry entry = (ZipEntry) e.nextElement(); System.out.println("File name: " + entry.getName() + "; size: " + entry.getSize() + "; compressed size: " + entry.getCompressedSize()); InputStream is = zip.getInputStream(entry); InputStreamReader isr = new InputStreamReader(is); char[] buffer = new char[1024]; while (isr.read(buffer, 0, buffer.length) != -1) { String s = new String(buffer); System.out.println(s.trim()); } } } }