Extract Zip File With Adler32 Checksum In Java

Chapter: ZIP Last Updated: 23-04-2016 03:40:42 UTC

Program:

            /* ............... START ............... */
                
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.Adler32;
import java.util.zip.CheckedInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class JavaExtractFileWithAdler32 {
	public static void main(String args[]) {

		String sourceZipFile = "C:/File/File.zip";

		try {
			// create FileInputStream from the source zip file
			FileInputStream fin = new FileInputStream(sourceZipFile);

			CheckedInputStream checksum = new CheckedInputStream(fin, new Adler32());

			ZipInputStream zin = new ZipInputStream(checksum);

			ZipEntry entry = zin.getNextEntry();

			// crate OutputStream to extract the entry from zip file
			OutputStream os = new FileOutputStream("c:/extract.txt");

			byte[] buffer = new byte[1024];
			int length;

			// read the entry from zip file and extract it to disk
			while ((length = zin.read(buffer)) > 0) {
				os.write(buffer, 0, length);
			}

			// close the streams
			os.close();

			zin.close();

			System.out.println("File Extracted from zip file");

			System.out.println("Adler32 checksum is: " + checksum.getChecksum().getValue());

		} catch (IOException e) {
			System.out.println("IOException :" + e);
		}

	}
}

                /* ............... END ............... */
        

Tags

Extract Zip File With Adler32, 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 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
Read Entries In Zip File In Java Example 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