All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.truevfs.comp.zip.Crc32Exception Maven / Gradle / Ivy

There is a newer version: 0.14.0
Show newest version
/*
 * Copyright (C) 2005-2015 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truevfs.comp.zip;

import java.util.zip.ZipException;

/**
 * Thrown to indicate a CRC32 mismatch between the declared value in the
 * Central File Header and the Data Descriptor or between the declared value
 * and the computed value from the decompressed data.
 * The prior case is detected on the call to {@link ZipFile#getCheckedInputStream},
 * whereas the latter case is detected when the input stream returned by this
 * method gets closed.
 * 

* The exception's detail message is the name of the ZIP entry. * * @author Christian Schlichtherle */ public class Crc32Exception extends ZipException { private static final long serialVersionUID = 1656298435298526391L; private final long expected, actual; /** * Creates a new instance of {@code Crc32Exception} where the * given entry name forms part of the detail message. * * @param name the entry name. * @param expected the declared CRC32 value. * @param actual the actual CRC32 value; * @see #getExpectedCrc * @see #getActualCrc */ Crc32Exception(final String name, final long expected, final long actual) { super(name + " (expected CRC32 value 0x" + Long.toHexString(expected) + ", but is actually 0x" + Long.toHexString(actual) + ")"); assert expected != actual; this.expected = expected; this.actual = actual; } /** * Returns the CRC32 value which has been expected for the ZIP entry. */ public long getExpectedCrc() { return expected; } /** * Returns the CRC32 value which has actually been found for the ZIP entry. */ public long getActualCrc() { return actual; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy