Package java.util.zip

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


        if (checkCRCs) {
          long readCRC = (((crcLengthBytes[0] & 0xff) << 24) + ((crcLengthBytes[1] & 0xff) << 16)
                  + ((crcLengthBytes[2] & 0xff) << 8) + (crcLengthBytes[3] & 0xff)) & 0x00000000ffffffffL;
          CRC32 crc = new CRC32();
          crc.update(chunkTypeBytes);
          if(length > 0)
                                            crc.update(chunkData);
          long computedCRC = crc.getValue();

          if (readCRC != computedCRC) {
View Full Code Here


          long readCRC = (((crcLengthBytes[0] & 0xff) << 24) + ((crcLengthBytes[1] & 0xff) << 16)
                  + ((crcLengthBytes[2] & 0xff) << 8) + (crcLengthBytes[3] & 0xff)) & 0x00000000ffffffffL;
          CRC32 crc = new CRC32();
          crc.update(chunkTypeBytes);
          if(length > 0)
                                            crc.update(chunkData);
          long computedCRC = crc.getValue();

          if (readCRC != computedCRC) {
            skip = true;
            if (logMINOR)
View Full Code Here

    @Override
    public boolean checkChecksum(byte[] data, int offset, int length, byte[] checksum) {
        if(checksum.length != 4) throw new IllegalArgumentException();
        CRC32 crc = new CRC32();
        crc.update(data, offset, length);
        int computed = (int)crc.getValue();
        int stored = Fields.bytesToInt(checksum);
        return computed == stored;
    }
View Full Code Here

    @Override
    public byte[] appendChecksum(byte[] data) {
        byte[] output = new byte[data.length+4];
        System.arraycopy(data, 0, output, 0, data.length);
        Checksum crc = new CRC32();
        crc.update(data, 0, data.length);
        byte[] checksum = Fields.intToBytes((int)crc.getValue());
        System.arraycopy(checksum, 0, output, data.length, 4);
        return output;
    }
View Full Code Here

    }

    @Override
    public byte[] generateChecksum(byte[] data, int offset, int length) {
        Checksum crc = new CRC32();
        crc.update(data, offset, length);
        return Fields.intToBytes((int)crc.getValue());
    }

    @Override
    public int getChecksumTypeID() {
View Full Code Here

                }
                throw new EOFException("stream reached eof");
            }
            if(read == 0) throw new IOException("stream returning 0 bytes");
            if(read != 0)
                crc.update(buffer, 0, read);
            destination.write(buffer, 0, read);
            if (remaining > 0)
                remaining -= read;
        }
        byte[] checksum = new byte[checksumLength()];
View Full Code Here

            while (true) {
                int read = input.read(buf);
                if (read < 0) {
                    break;
                }
                checksum.update(buf, 0, read);
            }
        } finally {
            input.close();
        }
        return checksum.getValue();
View Full Code Here

  private long getCRC(FileSystem fs, Path p) throws IOException {
    CRC32 crc = new CRC32();
    FSDataInputStream stm = fs.open(p);
    for (int b = 0; b > 0; b = stm.read()) {
      crc.update(b);
    }
    stm.close();
    return crc.getValue();
  }
View Full Code Here

  private long getCRC(FileSystem fs, Path p) throws IOException {
    CRC32 crc = new CRC32();
    FSDataInputStream stm = fs.open(p);
    for (int b = 0; b > 0; b = stm.read()) {
      crc.update(b);
    }
    stm.close();
    return crc.getValue();
  }
View Full Code Here

                    break;
                }

                ByteArrayInputStream bufIn = new ByteArrayInputStream(bytes);
                Checksum checksum = new CRC32();
                checksum.update(bytes, 0, bytes.length);
                if (claimedCRC32 != checksum.getValue())
                {
                    // this part of the log must not have been fsynced.  probably the rest is bad too,
                    // but just in case there is no harm in trying them.
                    continue;
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.