@Test public void testGenerateRandomString() throws Exception { final Map<String, String> generatedStrings = new HashMap<String, String>(100); for (int i = 0; i < 100; i++) { final String newString = Strings.generateRandomString(100); final String oldString = generatedStrings.get(newString); Assert.assertNull("Iteration " + i + "\nNew string: " + newString + "\nOld string: " + oldString, oldString); generatedStrings.put(newString, newString); } }
@Nonnull public static String generateRandomString(int length) { final StringBuilder result = new StringBuilder(length); for (int i = 0; i < length; i++) { final char ch; synchronized (RANDOM) { ch = (char) (RANDOM.nextInt(52) + 65); } result.append(ch); } return result.toString(); }
Strings { @Nonnull public static String generateRandomString(int length) { final StringBuilder result = new StringBuilder(length); for (int i = 0; i < length; i++) { final char ch; synchronized (RANDOM) { ch = (char) (RANDOM.nextInt(52) + 65); } result.append(ch); } return result.toString(); } }
Strings { @Nonnull public static String generateRandomString(int length) { final StringBuilder result = new StringBuilder(length); for (int i = 0; i < length; i++) { final char ch; synchronized (RANDOM) { ch = (char) (RANDOM.nextInt(52) + 65); } result.append(ch); } return result.toString(); } protected  Strings(); }
Strings { @Nonnull public static String generateRandomString(int length) { final StringBuilder result = new StringBuilder(length); for (int i = 0; i < length; i++) { final char ch; synchronized (RANDOM) { ch = (char) (RANDOM.nextInt(52) + 65); } result.append(ch); } return result.toString(); } protected  Strings(); static String[] split(String source, String subString); static String convertStream(InputStream in); static boolean notEmpty(@Nullable String s); static boolean isEmpty(@Nullable CharSequence s); @Nonnull static String getNotEmpty(@Nullable CharSequence s, @Nonnull String defaultValue); @Nonnull static String getNotEmpty(@Nullable T t, @Nonnull String defaultValue); static String[] toString(@Nonnull Enum... enums); @Nonnull static Character[] toObjects(char[] array); @Nonnull static String fromStackTrace(@Nullable StackTraceElement... stackTraceElements); @Nonnull static String repeat(@Nonnull String str, int repeat); @Nonnull static String repeat(char ch, int repeat); @Nonnull static String generateRandomString(int length); @Nonnull static String toHex(@Nonnull String s); @Nonnull static String fromHex(@Nonnull CharSequence hex); @Nonnull static String getAllEnumValues(@Nonnull Class<? extends Enum> enumClass); @Nonnull static String getAllValues(@Nonnull List<?> elements); @Nonnull static String toHtml(@Nonnull CharSequence text); }
Strings { @Nonnull public static String generateRandomString(int length) { final StringBuilder result = new StringBuilder(length); for (int i = 0; i < length; i++) { final char ch; synchronized (RANDOM) { ch = (char) (RANDOM.nextInt(52) + 65); } result.append(ch); } return result.toString(); } protected  Strings(); static String[] split(String source, String subString); static String convertStream(InputStream in); static boolean notEmpty(@Nullable String s); static boolean isEmpty(@Nullable CharSequence s); @Nonnull static String getNotEmpty(@Nullable CharSequence s, @Nonnull String defaultValue); @Nonnull static String getNotEmpty(@Nullable T t, @Nonnull String defaultValue); static String[] toString(@Nonnull Enum... enums); @Nonnull static Character[] toObjects(char[] array); @Nonnull static String fromStackTrace(@Nullable StackTraceElement... stackTraceElements); @Nonnull static String repeat(@Nonnull String str, int repeat); @Nonnull static String repeat(char ch, int repeat); @Nonnull static String generateRandomString(int length); @Nonnull static String toHex(@Nonnull String s); @Nonnull static String fromHex(@Nonnull CharSequence hex); @Nonnull static String getAllEnumValues(@Nonnull Class<? extends Enum> enumClass); @Nonnull static String getAllValues(@Nonnull List<?> elements); @Nonnull static String toHtml(@Nonnull CharSequence text); static final String LINE_SEPARATOR; static final Character[] EMPTY_CHARACTER_OBJECT_ARRAY; }