List of usage examples for com.google.common.io ByteSource read
@Beta public <T> T read(ByteProcessor<T> processor) throws IOException
From source file:net.derquinse.common.base.Digests.java
/** * Computes and returns as a byte string the digest of the provided data. *///from www . jav a2s. co m public static ByteString getDigest(ByteSource source, final MessageDigest md) throws IOException { checkNotNull(source); checkNotNull(md); final byte[] digest = source.read(new ByteProcessor<byte[]>() { @Override public boolean processBytes(byte[] buf, int off, int len) { md.update(buf, off, len); return true; } @Override public byte[] getResult() { return md.digest(); } }); return ByteString.copyFrom(digest); }