public static String randomString(int length) {
        Preconditions.checkArgument(length > MIN_PASSWORD_LENGTH, "random string length must be at least 1 character");
        Preconditions.checkArgument(length <= MAX_PASSWORD_LENGTH, "random string length must be at most 256 character");
        
        return RandomStringUtils.random(length, 0, CHARACTERS.length-1, false, false, CHARACTERS, new SecureRandom());
    }
public static String randomString ( int length ) { Preconditions . checkArgument ( length > MIN_PASSWORD_LENGTH , "random string length must be at least 1 character" ) ; Preconditions . checkArgument ( length <= MAX_PASSWORD_LENGTH , "random string length must be at most 256 character" ) ; return RandomStringUtils . random ( length , 0 , CHARACTERS . length - 1 , false , false , CHARACTERS , new SecureRandom ( ) ) ; }
Generates a random string with the given length.

Based on commons-lang3 RandomStringUtils using SecureRandom

Uses: uppercase letters, lowercase letters and numbers

@param length The length of the random string
@return A random String