Best code examples for Java 8 CRC32 class (java.util.zip.CRC32)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CRC32 class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 CRC32 examples from Open Source projects
This code example shows how to use the following methods: getValue, update
        return crc32(array, 0, array.length);
    } 
 
 
    public static final int crc32(byte[] array, int offset, int length) {
        CRC32 crc32 = new CRC32();
        crc32.update(array, offset, length);
        return (int) (crc32.getValue() & 0x7FFFFFFF);
    } 
} 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
    private final StreamOutput out;
    private final Checksum digest;
 
    public BufferedChecksumStreamOutput(StreamOutput out) {
        this.out = out;
        this.digest = new BufferedChecksum(new CRC32());
    } 
 
    public long getChecksum() { 
        return this.digest.getValue();
    } 
 
    @Override 
    public void writeByte(byte b) throws IOException {
        out.writeByte(b);
        digest.update(b);
    } 
 
    @Override 
    public void writeBytes(byte[] b, int offset, int length) throws IOException {
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getValue, reset, update
	/** 
	 * @tests java.util.zip.CRC32#getValue() 
	 */ 
	public void test_getValue() { 
		// test methods of java.util.zip.crc32.getValue() 
		CRC32 crc = new CRC32();
		assertEquals("getValue() should return a zero as a result of constructing a CRC32 instance",
				0, crc.getValue());
 
		crc.reset();
		crc.update(Integer.MAX_VALUE);
		// System.out.print("value of crc " + crc.getValue()); 
		// Ran JDK and discovered that the value of the CRC should be 
		// 4278190080 
		assertEquals("update(max) failed to update the checksum to the correct value ",
				4278190080L, crc.getValue());
 
		crc.reset();
		byte byteEmpty[] = new byte[10000];
		crc.update(byteEmpty);

7
CodeRank
This code example shows how to use the following methods: getValue, update
This code example shows how to use the following methods:
    private final StreamInput in;
    private final Checksum digest;
 
    public BufferedChecksumStreamInput(StreamInput in) {
        this.in = in;
        this.digest = new BufferedChecksum(new CRC32());
    } 
 
    public long getChecksum() { 
        return this.digest.getValue();
    } 
 
    @Override 
    public byte readByte() throws IOException {
        final byte b = in.readByte();
        digest.update(b);
        return b;
    } 
 
    @Override 
Full Snippet Info
7
CodeRank
Related Java 8 CRC32 Questions & Answers:
See Code Examples for Java 8 CRC32 Methods: