Home » zip

Tag Archives: zip

Create zip file from directory recursively with ZipOutputStream

In this example we shall show you how to create a zip file from a directory recursively, using ZipOutputStream. We have implemented a method to write a File to a ZipFile, with a ZipOutputStream. It is void addDirToArchive(ZipOutputStream zos, File srcFile). The steps of this method are described below: The method gets the array of Files of abstract pathnames denoting ...

Read More »

Create zip file from multiple files with ZipOutputStream

With this example we are going to demonstrate how to create a zip file from multiple Files with ZipOutputStream, that implements an output stream filter for writing files in the ZIP file format. In short, to create a zip file from multiple Files with ZipOutputStream you should: Create a FileOutputStream to write to the file with the specified name, that ...

Read More »

Create zip file from single file with ZipOutputStream

This is an example of how to create a zip file from a single File with ZipOutputStream. The ZipOutputStream class implements an output stream filter for writing files in the ZIP file format. Creating a zip file from a single File with ZipOutputStream implies that you should: Create a FileOutputStream to write to the file with the specified name, that ...

Read More »

Create zip file from directory with ZipOutputStream

In this example we shall show you how to create a zip file from a directory with ZipOutputStream class, that is an output stream filter for writing files in the ZIP file format. To create a zip file from a directory with ZipOutputStream one should perform the following steps: Create a FileOutputStream to write to the file with the specified ...

Read More »

Extract zip file with subdirectories

With this example we are going to demonstrate how to extract from a ZipFile With Subdirectories. In short, to extract from a ZipFile With Subdirectories you should: Create a new File instance by the given pathname of the file. Create a directory with the same name to which the contents will be extracted, using mkdir() API method of File. Create ...

Read More »

Search file in a zip file

This is an example of how to search a File in a zip file, using the ZipFile class. Searching a File in a zip file implies that you should: Create a new ZipFile and open it for reading. Get the enumeration of the ZipFile entries, with entries() API method of ZipFile and iterate through each one of them. For each ...

Read More »

List contents of zip file

In this example we shall show you how to get the list of the contents of a zip file, with ZipFile that is used to read entries from a zip file. To get the files that a zip file contains one should perform the following steps: Create a new ZipFile and open it for reading. Get the Enumeration of the ...

Read More »

Calculate CRC-32 checksum of zip entry

With this example we are going to demonstrate how to calculate the CRC-32 checksum of a ZipEntry. In short, to calculate the CRC-32 checksum of a ZipEntry you should: Create a new ZipFile and open it for reading. Get the Enumeration of the ZipFile entries, with entries() API method of ZipFile and iterate through each one of them. For each ...

Read More »

Get zip entry compression method

This is an example of how to get the ZipEntry Compression method. The compression method of a ZipEntry can be either STORED for uncompressed entries, or DEFLATED for compressed (deflated) entries. Getting the compression method of the ZipEntry implies that you should: Create a new ZipFile to read a zip file with the given name. Get the Enumeration of the ...

Read More »

Calculate CRC32 checksum for byte array

In this example we shall show you how to calculate the CRC32 Checksum of a byte array. To calculate the CRC32 checksum of a byte array one should perform the following steps: Get the byte array of a String, using getBytes() API method of String. Create a new Checksum object, that represents a data checksum. Update the current checksum with ...

Read More »