public static boolean doesStreamEqualStream(InputStream expected, InputStream actual) throws IOException {

        try {
            final byte[] expectedDigest = InputStreamUtils.calculateMD5Digest(expected);
            final byte[] actualDigest = InputStreamUtils.calculateMD5Digest(actual);

            return Arrays.equals(expectedDigest, actualDigest);
        } catch (NoSuchAlgorithmException nse) {
            throw new AmazonClientException(nse.getMessage(), nse);
        } finally {
            IOUtils.closeQuietly(expected, null);
            IOUtils.closeQuietly(actual, null);
        }
    }
Returns true if, and only if, the contents read from the specified input streams are exactly
equal. Both input streams will be closed at the end of this method.

@param expected
           The input stream containing the expected contents.
@param inputStream
           The stream that will be read, compared to the expected file contents, and finally
           closed.
@return True if the two input streams contain the same data.
@throws IOException
            If any problems are encountered comparing the file and stream.
aws-java-sdk-test-utils/src/main/java/com/amazonaws/test/util/SdkAsserts.java