I have zipped a folder containing files and folders using zip4j in Java. I want to validate created zip for -
- The number of files chosen before zipped?
- Whether files are not being corrupted during zip process?
Thanks
I have zipped a folder containing files and folders using zip4j in Java. I want to validate created zip for -
Thanks
What I'd do is extract the folder to a different location, use the standard POSIX find
and cmp
commands to compare the corresponding files in the original and extracted directories.
Please read through this snippet . http://www.java-examples.com/get-crc-32-checksum-zip-entry-example
You can catch the execption for the invalid checking of the file.
Look at the following snippet
while(e.hasMoreElements())
{
ZipEntry entry = (ZipEntry)e.nextElement();
/*
* To get CRC-32 checksum of an entry, use
*
* long getCrc()
* method of Java ZipEntry class.
*
* This method returns the CRC checksum for a particular
* zip entry, or -1 if not known.
*/
String entryName = entry.getName();
long crc = entry.getCrc();
System.out.print(entryName);
System.out.print("\t\t\t\t" + crc);
System.out.print("\n");
}
You can use this code and insert a static counter to count the files inside the zip. Coupling this code to your zipping logic should work just fine.