Package java.util.zip

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


                    }
                    return true;
                }
                final int expectedCRC = entryBuffer.getInt();
                final CRC32 crc = new CRC32();
                crc.update(entryBuffer.array(), 4, entryBuffer.capacity() - 4);
                final int actualCRC = (int)crc.getValue();

                if (expectedCRC != actualCRC) {
                    m_channel.close();
                    return false;
View Full Code Here


                    m_path + " position " + position);
        }
        final byte entryBytes[] = new byte[entryLength];
        dup.get(entryBytes);
        CRC32 crc = new CRC32();
        crc.update(entryBytes);
        final int actualCRC = (int)crc.getValue();

        if (actualCRC != originalCRC) {
            throw new IOException("CRC mismatch in record, retrieved from " +
                    m_path + " position " + position);
View Full Code Here

                    final int compressedLength = view.getInt();
                    byte compressedBytes[] = new byte[compressedLength ];
                    view.get(compressedBytes);

                    final CRC32 crc = new CRC32();
                    crc.update(compressedBytes);

                    final int actualCRC = (int)crc.getValue();
                    if (actualCRC != originalCRC) {
                        throw new RuntimeException("CRC mismatch");
                    }
View Full Code Here

        finalBuf.position(4);
        finalBuf.putInt(compressedBytes.length);
        finalBuf.put(compressedBytes);

        final CRC32 crc = new CRC32();
        crc.update(finalBuf.array(), 8, finalBuf.capacity() - 8);
        finalBuf.putInt(0, (int)crc.getValue());

        return new Object[] { finalBuf.array(), keyHash };
    }
View Full Code Here

        entryBuf.putInt(-1);
        entryBuf.put(keyHash);
        entryBuf.putLong(timestamp);

        final CRC32 crc = new CRC32();
        crc.update(entryBuf.array(), 4, entryBuf.capacity() - 4);
        entryBuf.putInt(0, (int)crc.getValue());

        return entryBuf.array();
    }
View Full Code Here

  public long crc() {
    CRC32 crc = new CRC32();

    int octets = byteSize();
    crc.update(data, byteOffset(), octets);
    return crc.getValue();
  }

  /**
   * @param barr
View Full Code Here

    return (this.getCRC() == crc);
  }

  public long getCRC() {
    CRC32 crc32 = new CRC32();
    crc32.update(this.type);
    crc32.update(this.data);

    return crc32.getValue();
  }
View Full Code Here

  }

  public long getCRC() {
    CRC32 crc32 = new CRC32();
    crc32.update(this.type);
    crc32.update(this.data);

    return crc32.getValue();
  }

  /**
 
View Full Code Here

 
    public static String getPath(String storePath,int taskIndex,int offset,FileSystem lfs)
    {
    CRC32 crc32 = new CRC32();
     crc32.update(String.valueOf(taskIndex).getBytes());
     long crcvalue = crc32.getValue();
     if(crcvalue<0)
      {
       crcvalue*=-1;
      }
 
View Full Code Here

    private static
        String getUnicodeStringIfOriginalMatches(AbstractUnicodeExtraField f,
                                                 byte[] orig) {
        if (f != null) {
            CRC32 crc32 = new CRC32();
            crc32.update(orig);
            long origCRC32 = crc32.getValue();

            if (origCRC32 == f.getNameCRC32()) {
                try {
                    return ZipEncodingHelper
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.