Java Random randomPseudo()

Here you can find the source of randomPseudo()

Description

random Pseudo

License

Open Source License

Declaration

public static String randomPseudo() 

Method Source Code

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

public class Main {
    public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
    public static final String VOWELS = "aeiouy";
    public static final String CONSONANTS = "bcdfghjklmnpqrstvwxz";

    public static String randomPseudo() {
        final int length = random(4, 8);
        StringBuilder sb = new StringBuilder(length);
        boolean flag = random(0, 1) == 1;
        for (int i = 0; i < length; ++i) {
            sb.append(flag ? random(VOWELS) : random(CONSONANTS));
            flag = !flag;/*  ww w  .j a  v  a  2s .co m*/
        }
        return sb.toString();
    }

    private static int random(int min, int max) {
        return (int) (Math.random() * max + min);
    }

    public static char random(String str) {
        return str.charAt(random(0, str.length()));
    }

    public static String random(int length) {
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; ++i)
            sb.append(random(ALPHABET));
        return sb.toString();
    }
}

Related

  1. randomPassword()
  2. randomPermutation(int size)
  3. randomPermutations(int[] tab, Random r)
  4. randomPermute(List l, Random rand)
  5. randomProbability(double probability)
  6. randomRange(int end)
  7. randomScalingFactor()
  8. randomSeed()
  9. randomShort()