code: public void write(byte[] b, int off, int len) throws IOException {
          // BEGIN Android-added: perform checks for parameters first.
          // See org.apache.harmony.security.tests.j.s.DigestOutputStreamTest#test_write$BII_6
          if (b == null || off + len > b.length) {
              throw new IllegalArgumentException("wrong parameters for write");
          }
          if (off < 0 || len < 0) {
              throw new IndexOutOfBoundsException("wrong index for write");
          }
          // END Android-added
          out.write(b, off, len);
          if (on) {
              digest.update(b, off, len);
          }
      }
docs: Updates the message digest (if the digest function is on) using
  the specified subarray, and in any case writes the subarray to
  the output stream. That is, if the digest function is on (see
  {@link #on(boolean) on}), this method calls {@code update}
  on the message digest associated with this stream, passing it
  the subarray specifications. This method then writes the subarray
  bytes to the output stream, blocking until the bytes are actually
  written.
  
  @param b the array containing the subarray to be used for updating
  and writing to the output stream.
  
  @param off the offset into {@code b} of the first byte to
  be updated and written.
  
  @param len the number of bytes of data to be updated and written
  from {@code b}, starting at offset {@code off}.
  
  @exception IOException if an I/O error occurs.
  
  @see MessageDigest#update(byte[], int, int)