Skip to content

Instantly share code, notes, and snippets.

@SergioLarios
Created June 8, 2016 07:53
Show Gist options
  • Save SergioLarios/b090ca9f798731d2529e74eb375b4877 to your computer and use it in GitHub Desktop.
Save SergioLarios/b090ca9f798731d2529e74eb375b4877 to your computer and use it in GitHub Desktop.
private static String nextRngString() {
for (int idx = 0; idx < buf.length; ++idx)
buf[idx] = symbols[random.nextInt(symbols.length)];
return new String(buf);
}
/* *****************************
* **** Private constants *****
***************************** */
static {
StringBuilder tmp = new StringBuilder();
for (char ch = '0'; ch <= '9'; ++ch)
tmp.append(ch);
for (char ch = 'a'; ch <= 'z'; ++ch)
tmp.append(ch);
symbols = tmp.toString().toCharArray();
}
private static final char[] symbols;
private static final Random random = new Random();
private static final char[] buf = new char[____NUMERO_DE_CARACTERES____];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment