code: public static byte[] fromBinaryString(String binaryStr) {
      if (!binaryStr.matches("^[01]*$"))
        throw new IllegalArgumentException("Invalid binary string");
      if (binaryStr.isEmpty()) return new byte[0];
  
      int complementary = binaryStr.length() % 8;
      if (complementary != 0)
        binaryStr += Ruby.Array.of("0").multiply(8 - complementary).join();
      return rjust(new BigInteger(binaryStr, 2).toByteArray(),
          binaryStr.length() / 8);
    }
docs: Converts a binary string into byte array.
  
  @param binaryStr
  a binary string
  @return byte array
  @throws IllegalArgumentException
  if binary string is invalid