code: private static String checkPayToHash(byte[] scriptPubKey) {
  // test start
  boolean validLength=scriptPubKey.length==25;
  if (!(validLength)) {
  	return null;
  }
  boolean validStart=((scriptPubKey[0] & 0xFF)==0x76) && ((scriptPubKey[1] & 0xFF)==0xA9) && ((scriptPubKey[2] & 0xFF)==0x14);
  boolean validEnd=((scriptPubKey[23] & 0xFF)==0x88) && ((scriptPubKey[24]  & 0xFF)==0xAC);
  
  	if (validStart && validEnd) {
  		byte[] bitcoinAddress = Arrays.copyOfRange(scriptPubKey, 3, 23);
  		return "bitcoinaddress_"+BitcoinUtil.convertByteArrayToHexString(bitcoinAddress);
  	} 
  	return null;
  }
docs: *
  Checks if scriptPubKey is about a transaction for paying to a hash
  
  @param scriptPubKey of transaction
  
  @return null, if transaction not about paying to hash, a string starting with "bitcoinaddress_" and ending with the hex values as String of the hash address