Package java.util.zip

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


    @Test
    public void testRecoveryWithBadSizeChecksum() throws Exception
    {
        Checksum checksum = new CRC32();
        checksum.update(100);
        testRecoveryWithBadSizeArgument(100, 100, ~checksum.getValue());
    }
   
    @Test
    public void testRecoveryWithZeroSegmentSizeArgument() throws Exception
View Full Code Here


        DataOutputStream dos = new DataOutputStream(out);
        Checksum checksum = new CRC32();

        // write the first checksum after the fixed-size part, so we won't read garbage lastFlushedAt data.
        dos.writeInt(1);
        checksum.update(1);
        dos.writeLong(checksum.getValue());
        dos.writeInt(0);
        checksum.update(0);
        dos.writeInt(200);
        checksum.update(200);
View Full Code Here

        // write the first checksum after the fixed-size part, so we won't read garbage lastFlushedAt data.
        dos.writeInt(1);
        checksum.update(1);
        dos.writeLong(checksum.getValue());
        dos.writeInt(0);
        checksum.update(0);
        dos.writeInt(200);
        checksum.update(200);
        dos.writeLong(checksum.getValue());
        dos.close();
View Full Code Here

        checksum.update(1);
        dos.writeLong(checksum.getValue());
        dos.writeInt(0);
        checksum.update(0);
        dos.writeInt(200);
        checksum.update(200);
        dos.writeLong(checksum.getValue());
        dos.close();

        testRecovery(out.toByteArray(), new byte[0]);
    }
View Full Code Here

    }

    protected void testRecoveryWithBadSizeArgument(int size, int dataSize) throws Exception
    {
        Checksum checksum = new CRC32();
        checksum.update(size);
        testRecoveryWithBadSizeArgument(size, dataSize, checksum.getValue());
    }

    protected void testRecoveryWithBadSizeArgument(int size, int dataSize, long checksum) throws Exception
    {
View Full Code Here

    return disposed;
  }
 
  public static long crc32(byte[] payload) {
    final Checksum checksum = new CRC32();
    checksum.update(payload,0,payload.length);
    return checksum.getValue();
  }

  public Pointer update(Pointer pointer, byte[] payload) {
    free(pointer);
View Full Code Here

  public long crc(String str) {
    final Checksum checksum = new CRC32();

    final byte bytes[] = str.getBytes();
    checksum.update(bytes,0,bytes.length);
    return checksum.getValue();
  }
 
  @BeforeClass
  @AfterClass
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

            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

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.