List of utility methods to do Random String
String | getRandomString(final int len) Get random string final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; final Random rnd = new Random(); final StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { sb.append(AB.charAt(rnd.nextInt(AB.length()))); return sb.toString(); |
String | getRandomString(final int length) returns a random string of characters (A-Z) of the specified length final StringBuffer sb = new StringBuffer(); final Random rand = new Random(); for (int i = 0; i < length; i++) sb.append((char) ((Math.abs(rand.nextInt()) % 26) + 65)); return sb.toString(); |
String | getRandomString(final int size) get Random String final StringBuilder randomString = new StringBuilder(size); for (int i = 0; i < size; i++) { randomString.append(getRandomCharacter()); return randomString.toString(); |
String | getRandomString(final int size) Creates a random alpha-numeric String of given length StringBuilder sb = new StringBuilder(size); for (int i = 0; i < size; i++) { sb.append(AB.charAt(rnd.nextInt(AB.length()))); return sb.toString(); |
String | getRandomString(int cantidad, boolean mayusculas, boolean minusculas, boolean numeros, boolean simbolos, boolean repetir) get Random String String vNumeros = "0123456789"; String vMayusculas = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String vMinusculas = "abcdefghijklmnopqrstuvwxyz"; String vSimbolos = "!@#$%&*-_+,./|:;()[]{}<>?= "; StringBuilder busqueda = new StringBuilder(); if (mayusculas) { busqueda.append(vMayusculas); if (minusculas) { busqueda.append(vMinusculas); if (numeros) { busqueda.append(vNumeros); if (simbolos) { busqueda.append(vSimbolos); return getRandomString(cantidad, busqueda.toString(), repetir); |
String | getRandomString(int count) get Random String StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) sb.append(getRandomChar()); return sb.toString(); |
String | getRandomString(int len) A random lower case string Random rnd = getRandom(); char[] s = new char[len]; for (int i = 0; i < len; i++) { char c; if (rnd.nextInt(3) == 0) { c = vowels[rnd.nextInt(vowels.length)]; } else { c = consonants[rnd.nextInt(consonants.length)]; ... |
String | getRandomString(int len) Get a random string with the request length Random rand = new Random(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < len; i++) { sb = sb.append(RANDOM_CHARSET[rand.nextInt(RANDOM_CHARSET.length)]); return sb.toString(); |
String | getRandomString(int len) Generate a string of random characters of the given length. Random rnd = new Random(); StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { sb.append(RANDOM_CHARACTERS.charAt(rnd.nextInt(RANDOM_CHARACTERS.length()))); return sb.toString(); |
String | getRandomString(int len) get Random String return getRandomString(len, RANDOM_TYPE_NORMAL);
|