Code example for DigestOutputStream

0
 */ 
public class Digester implements DataOutput {
 
    public static final String ALGORITHM = "SHA-1";
 
    private final DigestOutputStream digester = new DigestOutputStream(new NullOutputStream(), messageDigest());
    private final DataOutputStream data = new DataOutputStream(digester);
 
    @NotNull 
    private static MessageDigest messageDigest() {
        try { 
            return MessageDigest.getInstance(ALGORITHM);
        } 
        catch ( NoSuchAlgorithmException e ) {
            throw new UnexpectedException(e);
        } 
    } 
 
    private byte[] digest = null;
 
    @Override