Package java.util.zip

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


        name = alternateNames[i];

      // Add ZIP entry to output stream.
      ZipEntry entry = new ZipEntry(name);
      out.putNextEntry(entry);
      crc.reset();

      // Transfer bytes from the file to the ZIP file
      int len;
      while((len = in.read(buf)) > 0)
      {
View Full Code Here


        String path = files[i].getPath().substring(base.getPath().length() + 1);

        FileInputStream in = new FileInputStream(files[i]);
        ZipEntry entry = new ZipEntry(path);
        zos.putNextEntry(entry);
        crc.reset();

        while((read = in.read(buffer)) > 0)
        {
          zos.write(buffer, 0, read);
          crc.update(buffer, 0, read);
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

            synchronized(checksum) {
                CRC32 csumAlgo = checksum.get();
                try {
                    payload = le.serialize(csumAlgo);
                } finally {
                    csumAlgo.reset();
                }
            }
           
            // send the LogEntry to the other servers
            for (final SlaveClient slave : slaves) {
View Full Code Here

    public void testReplicateRequest() throws Exception {
       
        // serialize the request
        Checksum csumAlgo = new CRC32();
        ReusableBuffer data = testEntry.serialize(csumAlgo);
        csumAlgo.reset();
       
        client.replicate(testLSN, data).get();
    }

    /* (non-Javadoc)
 
View Full Code Here

        // start header
        final ByteArrayOutputStream startHeaderBaos = new ByteArrayOutputStream();
        final DataOutputStream startHeaderStream = new DataOutputStream(startHeaderBaos);
        startHeaderStream.writeLong(Long.reverseBytes(headerPosition - SevenZFile.SIGNATURE_HEADER_SIZE));
        startHeaderStream.writeLong(Long.reverseBytes(0xffffFFFFL & headerBytes.length));
        crc32.reset();
        crc32.update(headerBytes);
        startHeaderStream.writeInt(Integer.reverseBytes((int)crc32.getValue()));
        startHeaderStream.flush();
        final byte[] startHeaderBytes = startHeaderBaos.toByteArray();
        crc32.reset();
View Full Code Here

        crc32.reset();
        crc32.update(headerBytes);
        startHeaderStream.writeInt(Integer.reverseBytes((int)crc32.getValue()));
        startHeaderStream.flush();
        final byte[] startHeaderBytes = startHeaderBaos.toByteArray();
        crc32.reset();
        crc32.update(startHeaderBytes);
        file.writeInt(Integer.reverseBytes((int) crc32.getValue()));
        file.write(startHeaderBytes);
    }
   
View Full Code Here

        // start header
        final ByteArrayOutputStream startHeaderBaos = new ByteArrayOutputStream();
        final DataOutputStream startHeaderStream = new DataOutputStream(startHeaderBaos);
        startHeaderStream.writeLong(Long.reverseBytes(headerPosition - SevenZFile.SIGNATURE_HEADER_SIZE));
        startHeaderStream.writeLong(Long.reverseBytes(0xffffFFFFL & headerBytes.length));
        crc32.reset();
        crc32.update(headerBytes);
        startHeaderStream.writeInt(Integer.reverseBytes((int)crc32.getValue()));
        startHeaderStream.flush();
        final byte[] startHeaderBytes = startHeaderBaos.toByteArray();
        crc32.reset();
View Full Code Here

        crc32.reset();
        crc32.update(headerBytes);
        startHeaderStream.writeInt(Integer.reverseBytes((int)crc32.getValue()));
        startHeaderStream.flush();
        final byte[] startHeaderBytes = startHeaderBaos.toByteArray();
        crc32.reset();
        crc32.update(startHeaderBytes);
        file.writeInt(Integer.reverseBytes((int)crc32.getValue()));
        file.write(startHeaderBytes);
    }
   
View Full Code Here

                        // writeUTF/writeWithShortLength) and 4 bytes for column count.
                        // This prevents CRC by being fooled by special-case garbage in the file; see CASSANDRA-2128
                        if (serializedSize < 10)
                            break;
                        long claimedSizeChecksum = reader.readLong();
                        checksum.reset();
                        checksum.update(serializedSize);
                        if (checksum.getValue() != claimedSizeChecksum)
                            break; // entry wasn't synced correctly/fully.  that's ok.

                        if (serializedSize > bytes.length)
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.