Checksum getValue - 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 getValue 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:getValue
        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 {
        out.writeBytes(b, offset, length);
        digest.update(b, offset, length);
    } 
 
7
CodeRank
This code example shows how to use the following methods:getValue, reset
     if ( type.size <= 0 ) {
       return 0; 
     } 
 
     if ( type.size == 4 ) {
       out.writeInt( (int) summer.getValue() );
     } else { 
       throw new IOException( "Unknown Checksum " + type );
     } 
      
     if ( reset ) {
       reset(); 
     } 
      
     return type.size;
   } 
    
   /** 
    * Writes the current checksum to a buffer. 
    * If <i>reset</i> is true, then resets the checksum. 

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:getValue
        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 
    public void readBytes(byte[] b, int offset, int len) throws IOException {
        in.readBytes(b, offset, len);
        digest.update(b, offset, len);
    } 
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:getValue
    digest.update(b, offset, len);
  } 
 
  @Override 
  public long getChecksum() { 
    return digest.getValue();
  } 
 
  @Override 
  public void close() throws IOException {
    main.close();
  } 
 
  @Override 
  public long getFilePointer() { 
    return main.getFilePointer();
  } 
 
  @Override 
  public long length() { 
6
CodeRank
This code example shows how to use the following methods:getValue, update
  public static String calculateChecksum(String message) {
 
    // get bytes from string 
    byte bytes[] = message.getBytes();
 
    Checksum checksum = new CRC32();
 
    // update the current checksum with the specified array of bytes 
    checksum.update(bytes, 0, bytes.length);
 
    // get the current checksum value 
    long checksumValue = checksum.getValue();
    return String.valueOf(checksumValue);
  } 
 
  /** 
   * Hexadecimal string representing a uuid4 value. 
   * 
   * @return Hexadecimal UUID4 String 
   */ 
6
CodeRank

Related Checksum getValue Questions & Answers:

getValue Method Overview
Returns the current checksum value.
See Code Examples for other Java 8 Checksum Methods: