Java Utililty Methods Random Char

List of utility methods to do Random Char

Description

The list of methods to do Random Char are organized into topic(s).

Method

charcreateRandomChar()
create Random Char
return (char) ('a' + (Math.random() * ('z' - 'a')));
StringgetRandomChar()
get Random Char
Random random = new Random();
String[] s = { "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T",
        "U", "V", "W", "X", "Y", "Z" };
String rand = "";
if (random.nextBoolean()) {
    rand = String.valueOf(random.nextInt(10));
} else {
    int index = random.nextInt(25);
...
chargetRandomChar()
get Random Char
int value = getRandom().nextInt(94) + 32;
char c = (char) ((value == 34 || value == 39 || value == 92) ? value + (getRandom().nextBoolean() ? 1 : -1)
        : value);
return c;
StringgetRandomChar()
get Random Char
Random i = new Random();
return chars[i.nextInt(chars.length)];
chargetRandomChar(boolean number, boolean lower, boolean upper, boolean other, String extra, Random _random)
Von http://www.jswelt.de/showsource.php?id=1123706440
String charSet = extra;
if (number == true)
    charSet += numberCharacters;
if (lower == true)
    charSet += lowerCharacters;
if (upper == true)
    charSet += upperCharacters;
if (other == true)
...
StringgetRandomChar(int size)
Description:
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; i++) {
    switch (RANDOM.nextInt(10) % 3) {
    case 0:
        sb.append((char) ('0' + RANDOM.nextInt(10)));
        break;
    case 1:
        sb.append((char) ('a' + RANDOM.nextInt(26)));
...
chargetRandomChar(int x)
Gets random char.
Random r = new Random();
char c = '0';
switch (x) {
case 0:
    c = (char) (r.nextInt(10) + 48); 
    break;
case 1:
    c = (char) (r.nextInt(26) + 97); 
...
chargetRandomChar(int[][] ranges, char differentThen, boolean caseSensitive, Random random)
Get a random char in given ranges, different than given char
ArrayList<Character> chars = getAllCharsInRange(ranges);
if (differentThen != ' ') {
    if (caseSensitive) {
        chars.remove(new Character(differentThen));
    } else {
        chars.remove(new Character((char) ((differentThen + "").toUpperCase().charAt(0))));
        chars.remove(new Character((char) ((differentThen + "").toLowerCase().charAt(0))));
int index = getRandomInt(0, chars.size() - 1, random);
return chars.get(index);
StringgetRandomChar(Random random, boolean upper)
get Random Char
int r = random.nextInt(26);
return upper ? "" + (char) ((int) 'A' + r) : "" + (char) ((int) 'a' + r);
chargetRandomChar(Random random, int type)
The next two methods are used to generate the random password for the self-signed certificate.
char generatedChar;
int next = random.nextInt();
int d;
switch (type) {
case 0:
    d = next % 10;
    if (d < 0) {
        d = d * -1;
...