Code example for DigestOutputStream

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);
    private static MessageDigest messageDigest() {
        try { 
            return MessageDigest.getInstance(ALGORITHM);
        catch ( NoSuchAlgorithmException e ) {
            throw new UnexpectedException(e);
    private byte[] digest = null;
Connect your IDE to all the code out there  Get Codota for Java