Java Random String getRandomNumberString(int length)

Here you can find the source of getRandomNumberString(int length)

Description

get Random Number String

License

Open Source License

Declaration

public static String getRandomNumberString(int length) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static final char[] CHARACTERS = { //indexes
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', //0-7
            'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', //8-15
            'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', //16-23
            'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //24-31
            'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', //32-39
            'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //40-47
            'w', 'x', 'y', 'z', '0', '1', '2', '3', //48-55
            '4', '5', '6', '7', '8', '9' //56-61
    };/*  ww w  .  j  av  a2  s .  c  o m*/

    public static String getRandomNumberString(int length) {
        Random generator = new Random();
        char str[] = new char[length];
        for (int i = 0; i < length; i++) {
            str[i] = CHARACTERS[51 + generator.nextInt(10)];
        }
        return new String(str);

    }
}

Related

  1. getDefaultRandomName(String namePrefix)
  2. getRandomAString(int min, int max)
  3. getRandomColors(final int size, final List colors)
  4. getRandomElementOrCompound(String equation)
  5. getRandomFromTier(int tier, String lvlRange)
  6. getRandomNumberString(int maxValue, int strLen)
  7. getRandomNumberStringBase36(int strLen)
  8. getRandomStr()
  9. getRandomStr()