public static boolean compareStreams ( InputStream in1 , InputStream in2 ) throws IOException { boolean moreOnIn1 ; do { int v1 = in1 . read ( ) ; int v2 = in2 . read ( ) ; if ( v1 != v2 ) { return false ; } moreOnIn1 = v1 != - 1 ; } while ( moreOnIn1 ) ; boolean noMoreOnIn2Either = in2 . read ( ) == - 1 ; return noMoreOnIn2Either ; }
Compares if two streams are identical in their contents .