code: public static String randomString(int length, int min, int max, @NonNull CharMatcher validChar) {
        if (length <= 0) {
           return EMPTY;
        }
        Random random = new Random();
        int maxRandom = max - min;
        char[] array = new char[length];
        for (int i = 0; i < array.length; i++) {
           char c;
           do {
              c = (char) (random.nextInt(maxRandom) + min);
           } while (Character.isLowSurrogate(c) ||
                       Character.isHighSurrogate(c) ||
                       !validChar.matches(c));
           array[i] = c;
        }
        return new String(array);
     }
docs: Generates a random string of a given length
  
  @param length    The length of the string
  @param min       The min character in the string
  @param max       The max character in the string
  @param validChar CharPredicate that must match for a character to be returned in the string
  @return A string of random characters