public boolean equalByteArrays(byte[] buf1,byte[] buf2) throws IOException {
  ByteArrayInputStream b1=new ByteArrayInputStream(buf1);
  ByteArrayInputStream b2=new ByteArrayInputStream(buf2);
  for (int i=0; i < b1.available(); ) {
    int byte1=b1.read();
    int byte2=b2.read();
    if (byte1 != byte2) {
      b1.close();
      b2.close();
      return false;
    }
  }
  b1.close();
  b2.close();
  return true;
}

public boolean equalByteArrays ( byte [ ] buf1 , byte [ ] buf2 ) throws IOException { ByteArrayInputStream b1 = new ByteArrayInputStream ( buf1 ) ; ByteArrayInputStream b2 = new ByteArrayInputStream ( buf2 ) ; for ( int i = 0 ; i < b1 . available ( ) ; ) { int byte1 = b1 . read ( ) ; int byte2 = b2 . read ( ) ; if ( byte1 != byte2 ) { b1 . close ( ) ; b2 . close ( ) ; return false ; } } b1 . close ( ) ; b2 . close ( ) ; return true ; }
finds out whether the bytes [ ] are equal
