Checksum update - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Checksum update method.

This code example shows how to use the following methods:getValue, reset, update
  private int write1(byte b[], int off, int len) throws IOException {
    if(count==0 && len>=buf.length) {
      // local buffer is empty and user data has one chunk 
      // checksum and output data 
      final int length = buf.length;
      sum.update(b, off, length);
      writeChecksumChunk(b, off, length, false);
      return length;
    } 
     
    // copy user data to local buffer 
    int bytesToCopy = buf.length-count;
    bytesToCopy = (len<bytesToCopy) ? len : bytesToCopy;
    sum.update(b, off, bytesToCopy);
    System.arraycopy(b, off, buf, count, bytesToCopy);
    count += bytesToCopy;
    if (count == buf.length) {
      // local buffer is full 
      flushBuffer(); 
    }  

8
CodeRank
This code example shows how to use the following methods:update
    } 
 
    @Override 
    public void writeBytes(byte[] b, int offset, int length) throws IOException {
        out.writeBytes(b, offset, length);
        digest.update(b, offset, length);
    } 
 
    @Override 
    public void flush() throws IOException { 
        out.flush();
    } 
 
    @Override 
    public void close() throws IOException { 
        out.close();
    } 
 
    @Override 
    public long getFilePointer() { 
8
CodeRank
This code example shows how to use the following methods:update
    } 
 
    @Override 
    protected void flushBuffer(byte[] b, int offset, int len) throws IOException {
        out.writeBytes(b, offset, len);
        digest.update(b, offset, len);
    } 
 
    // don't override it, base class method simple reads from input and writes to this output 
//        @Override public void copyBytes(IndexInput input, long numBytes) throws IOException { 
//            delegate.copyBytes(input, numBytes); 
//        } 
 
    @Override 
    public void flush() throws IOException { 
        super.flush(); 
        out.flush();
    } 
 
    @Override 
8
CodeRank
This code example shows how to use the following methods:update
    } 
 
    @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 {
        out.writeBytes(b, offset, length);
        digest.update(b, offset, length);
    } 
 
    @Override 
    public void flush() throws IOException {
        out.flush();
    } 
 
    @Override 
7
CodeRank
This code example shows how to use the following methods:getValue, update
 
    @Implementation 
    public static Bitmap decodeByteArray(byte[] data, int offset, int length, BitmapFactory.Options opts) {
        String desc = new String(data);
        if (!Charset.forName("US-ASCII").newEncoder().canEncode(desc)) {
            Checksum checksumEngine = new CRC32();
            checksumEngine.update(data, 0, data.length);
 
            desc = "byte array, checksum: " + checksumEngine.getValue();
        } 
 
        if (offset != 0 || length != data.length) {
            desc += " bytes " + offset + ".." + length;
        } 
        return create(desc, opts);
    } 
     
    static Bitmap create(String name) {
        return create(name, null);
    } 
8
CodeRank
This code example shows how to use the following methods:update
    } 
 
    @Override 
    public byte readByte() throws IOException {
        final byte b = in.readByte();
        digest.update(b);
        return b;
    } 
 
    @Override 
    public void readBytes(byte[] b, int offset, int len) throws IOException {
        in.readBytes(b, offset, len);
        digest.update(b, offset, len);
    } 
 
    @Override 
    public void reset() throws IOException {
        in.reset();
        digest.reset();
    } 
7
CodeRank
This code example shows how to use the following methods:getValue, reset, update
  private int write1(byte b[], int off, int len) throws IOException {
    if(count==0 && len>=buf.length) {
      // local buffer is empty and user data has one chunk 
      // checksum and output data 
      final int length = buf.length;
      sum.update(b, off, length);
      writeChecksumChunk(b, off, length, false);
      return length;
    } 
     
    // copy user data to local buffer 
    int bytesToCopy = buf.length-count;
    bytesToCopy = (len<bytesToCopy) ? len : bytesToCopy;
    sum.update(b, off, bytesToCopy);
    System.arraycopy(b, off, buf, count, bytesToCopy);
    count += bytesToCopy;
    if (count == buf.length) {
      // local buffer is full 
      flushBuffer(); 
    }  

7
CodeRank
This code example shows how to use the following methods:getValue, update
  } 
 
  @Override 
  public long getValue() { 
    flush(); 
    return in.getValue();
  } 
 
  @Override 
  public void reset() { 
    upto = 0;
    in.reset();
  } 
   
  private void flush() { 
    if (upto > 0) {
      in.update(buffer, 0, upto);
    } 
    upto = 0;
  } 

7
CodeRank
This code example shows how to use the following methods:getValue, update
			} 
		} 
	} 
 
    public static long calculateChecksum(byte[] data) {
        Checksum sum = new CRC32();
        sum.update(data, 0, data.length);
        return sum.getValue();
    } 
 
    /** 
     * Quietly (no exceptions) close Closable resource. In case of error it will 
     * be printed to {@link IOUtils} class logger. 
     *  
     * @param closeable 
     *            resource to close 
     */ 
    public static void closeQuietly( final Closeable closeable )
    { 
        try 
6
CodeRank
This code example shows how to use the following methods:update
    inSum = 0;
  } 
  @Override 
  public void update( byte[] b, int off, int len ) {
    if ( len > 0 ) {
      summer.update( b, off, len );
      inSum += len;
    } 
  } 
  @Override 
  public void update( int b ) {
    summer.update( b );
    inSum += 1;
  } 
   
  /** 
   * Verify that the given checksums match the given data. 
   *  
   * The 'mark' of the ByteBuffer parameters may be modified by this function,. 
   * but the position is maintained. 
6
CodeRank

Related Checksum update Questions & Answers:

update Method Overview
Updates the current checksum with the specified array of bytes.
See Code Examples for other Java 8 Checksum Methods: