@Test public void testCreateRandomString() { testCreateRandomString("0123456789", 1024); testCreateRandomString("abcdefghijklmnopqrstuvwxyz", 1024); testCreateRandomString("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1024); testCreateRandomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 1024); }
@NonNull public static String createRandomString(final String availableChars, final int count) { final StringBuilder result = new StringBuilder(); for (int i = 0; i < count; i++) { int idx = secureRandom.nextInt(availableChars.length()); char nextChar = availableChars.charAt(idx); result.append(nextChar); } return result.toString(); }
StringUtils { @NonNull public static String createRandomString(final String availableChars, final int count) { final StringBuilder result = new StringBuilder(); for (int i = 0; i < count; i++) { int idx = secureRandom.nextInt(availableChars.length()); char nextChar = availableChars.charAt(idx); result.append(nextChar); } return result.toString(); } }
StringUtils { @NonNull public static String createRandomString(final String availableChars, final int count) { final StringBuilder result = new StringBuilder(); for (int i = 0; i < count; i++) { int idx = secureRandom.nextInt(availableChars.length()); char nextChar = availableChars.charAt(idx); result.append(nextChar); } return result.toString(); } private  StringUtils(); }
StringUtils { @NonNull public static String createRandomString(final String availableChars, final int count) { final StringBuilder result = new StringBuilder(); for (int i = 0; i < count; i++) { int idx = secureRandom.nextInt(availableChars.length()); char nextChar = availableChars.charAt(idx); result.append(nextChar); } return result.toString(); } private  StringUtils(); @NonNull static String createRandomAlphaNumeric(final int count); @NonNull static String createRandomString(final String availableChars, final int count); @NonNull static String createString(final char startChar, final char endChar); }
StringUtils { @NonNull public static String createRandomString(final String availableChars, final int count) { final StringBuilder result = new StringBuilder(); for (int i = 0; i < count; i++) { int idx = secureRandom.nextInt(availableChars.length()); char nextChar = availableChars.charAt(idx); result.append(nextChar); } return result.toString(); } private  StringUtils(); @NonNull static String createRandomAlphaNumeric(final int count); @NonNull static String createRandomString(final String availableChars, final int count); @NonNull static String createString(final char startChar, final char endChar);  }