Read Entries In Zip File In Java Example

Chapter: ZIP Last Updated: 20-07-2016 03:31:27 UTC

Program:

            /* ............... START ............... */
                
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 JavaReadEntriesZip {
	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());
			}
		}
	}
}
                /* ............... END ............... */
        

Tags

Read Entries In A Zip File, Java

Similar Programs Chapter Last Updated
Zip Entry Is Directory Example In Java ZIP 23-04-2016
Create Zip File With CRC32 Checksum In Java ZIP 23-04-2016
Create Zip File With Adler32 Checksum In Java ZIP 23-04-2016
Extract Zip File With Adler32 Checksum In Java ZIP 23-04-2016
Extract File With CRC32 Checksum In Java ZIP 23-04-2016
CRC32 Checksum In Java ZIP 10-08-2016
Adler32 Checksum In Java ZIP 23-04-2016
Read Zip File Checksum Value In Java Example ZIP 20-07-2016
Create Checksum For Zip File In Java ZIP 07-08-2017
Decompress Zip File Using ZipInputStream In Java ZIP 20-07-2016
List The Contents Of Zip File In Java Example ZIP 07-08-2017
Extract Contents Of Zip File In Java Example ZIP 07-08-2017
Zip File Creation In Java Example ZIP 23-06-2016

1