title: Why DigestOutputStream cast int to byte?
body: <p>The <code>DigestOutputStream</code> calculates hash of its content, for example MD5 hash. If we look at its source we'll see:</p>
  
  <pre><code>public void write(int b) throws IOException {
      digest.update((byte)b);
      out.write(b);
  }
  </code></pre>
  
  <p>It casts <code>int</code> (32 bits) to <code>byte</code> (8 bits). Is it ok to do such casting?</p>