write
public static MD5 write(java.io.InputStream is,
java.io.OutputStream os,
MD5 md5)
throws java.io.IOException
Reads from the given input stream and writes the contents out to the given OutputStream. During the write, the MD5
sum from input stream is calculated and compared with the given MD5 sum. This does not close the InputStream but
DOES close the OutputStream so that the data gets flushed out correctly.
- Parameters:
is
- The InputStream to read from. This InputStream is wrapped in a BufferedInputStream for performance.
os
- The OutputStream to write to.
md5
- (Optional) The MD5 sum to check against.
- Returns:
- The MD5 checksum of the file that was written out. This helps in case the caller needs the sum and the
parameter is not given.
- Throws:
java.io.IOException
- If the output operation fails.
MD5Exception
- If the MD5 check failed.