public static boolean streamContentEquals(InputStream s1,InputStream s2) throws IOException {
  try {
    int b1, b2;
    do {
      b1=s1.read();
      b2=s2.read();
    }
 while ((b1 == b2) && (b1 != -1));
    return b1 == b2;
  }
  finally {
    try {
      s1.close();
      s2.close();
    }
 catch (    Exception e) {
    }
  }
}

public static boolean streamContentEquals ( InputStream s1 , InputStream s2 ) throws IOException { try { int b1 , b2 ; do { b1 = s1 . read ( ) ; b2 = s2 . read ( ) ; } while ( ( b1 == b2 ) && ( b1 != - 1 ) ) ; return b1 == b2 ; } finally { try { s1 . close ( ) ; s2 . close ( ) ; } catch ( Exception e ) { } } }
checks if both inputstreams have the same content and length . the streams are closed after reading .
