Package java.util.zip

Examples of java.util.zip.CRC32.reset()


      for (int b = 0; b < numBlocks; b++) {
        int chunkSize = (int) Math.min(BLOCK_SIZE, (size-(b*BLOCK_SIZE)));
        byte[] buf = new byte[chunkSize];
       
        in.read(buf);
        crc.reset();
        crc.update(buf);
       
        assertEquals(("Block crc " + b + " did not match on iteration " + i),
                     blockCrcs[b], crc.getValue());
      }
View Full Code Here


    throws IOException {
   
    PrintStream ps = out instanceof PrintStream ? (PrintStream)out : null;
    byte buf[] = new byte[buffSize];
    Checksum sum = new CRC32();
    sum.reset();
    try {
      int bytesRead = in.read(buf);
      while (bytesRead >= 0) {
        sum.update(buf, 0, bytesRead);
        out.write(buf, 0, bytesRead);
View Full Code Here

  private static void writeStored(final File f, final FileInputStream fis,
      final ZipOutputStream zos, final File root) throws IOException {
    final byte[] bytes = IOUtils.toByteArray(fis);

    final CRC32 crc = new CRC32();
    crc.reset();
    crc.update(bytes);

    final ZipEntry anEntry = new ZipEntry(
        FilenameUtils.separatorsToUnix(StringUtils.removeStart(f.getPath(),
            root.getPath() + File.separator)));
View Full Code Here

        try {
            long millis = System.currentTimeMillis();
            CRC32 checksum;
            if (VERIFY) {
                checksum = new CRC32();
                checksum.reset();
            }
            final byte[] buffer = new byte[BUFFER_SIZE];
            int bytesRead = in.read(buffer);
            while (bytesRead >= 0) {
                if (VERIFY) {
View Full Code Here

        if (onDiskChecksum != checksum.getValue())
        {
            // try again using new checksum object to be doubly sure
            CRC32 newChecksum = new CRC32();
            newChecksum.reset();
            newChecksum.update(pageData, 0, getPageSize()-CHECKSUM_SIZE);
            if (onDiskChecksum != newChecksum.getValue())
            {
                throw StandardException.newException(
                    SQLState.FILE_BAD_CHECKSUM,
View Full Code Here

            System.err.println("Skipping: " + fileName);
            return;
        }
        BufferedInputStream bis = new BufferedInputStream(
            new FileInputStream(file));
        crc.reset();
        while ((bytesRead = bis.read(buffer)) != -1) {
            crc.update(buffer, 0, bytesRead);
        }
        bis.close();
        bis = new BufferedInputStream(
View Full Code Here

            s.setLevel(6);

            ZipEntry entry = new ZipEntry(osgiInfoLog);
            entry.setSize((long) buf.length);
            crc.reset();
            crc.update(buf);
            entry.setCrc(crc.getValue());
            s.putNextEntry(entry);
            s.write(buf, 0, buf.length);
            s.finish();
View Full Code Here

    // write chunk size, type and data
    out.write(intArray, 0, 8);
    out.write(data, 0, chunkSize);
    // create checksum on type and data
    CRC32 checksum = new CRC32();
    checksum.reset();
    checksum.update(intArray, 4, 4);
    checksum.update(data, 0, chunkSize);
    // put checksum into byte array
    ArrayConverter.setIntBE(intArray, 0, (int)checksum.getValue());
    // and write it to output
View Full Code Here

    if (onDiskChecksum != checksum.getValue())
    {
      // try again using new checksum object to be doubly sure
      CRC32 newChecksum = new CRC32();
      newChecksum.reset();
      newChecksum.update(pageData, 0, getPageSize()-CHECKSUM_SIZE);
      if (onDiskChecksum != newChecksum.getValue())
      {
        throw StandardException.newException(
                    SQLState.FILE_BAD_CHECKSUM,
View Full Code Here

    if (onDiskChecksum != checksum.getValue())
    {
      // try again using new checksum object to be doubly sure
      CRC32 newChecksum = new CRC32();
      newChecksum.reset();
      newChecksum.update(pageData, 0, getPageSize()-CHECKSUM_SIZE);
      if (onDiskChecksum != newChecksum.getValue())
      {
        throw StandardException.newException(
                    SQLState.FILE_BAD_CHECKSUM,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.