Random string generation in Java
If the length is always identical you can save 1000000 calls to new().

Because new String(char[]) uses Arrays.copyOf(), you don't need a new char[] in every loop.

private static int ourlen = 1024;
private static char[] chars = new char[ourlen];

public static String getAlphaNumeric() {
    for (int i = 0; i &lt; ourlen; i++) {
        chars[i] = ch[random.nextInt(ch.length)];
    }
    return new String(c);
}