Java Password Generate generateString(String alphabet, int length)

Here you can find the source of generateString(String alphabet, int length)

Description

generate String

License

Open Source License

Declaration

public static String generateString(String alphabet, int length) 

Method Source Code

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

import java.util.Random;

public class Main {
    public static final Random random = new Random();

    public static String generateString(String alphabet, int length) {
        if (alphabet.length() == 0)
            return null;
        StringBuilder ret = new StringBuilder(length);
        for (int i = 0; i < length; ++i)
            ret.append(alphabet.charAt(random.nextInt(alphabet.length())));
        return ret.toString();
    }//  w w w.java2  s  .  c om
}

Related

  1. generateString(int length)
  2. generateString(int length)
  3. generateString(int length)
  4. GenerateString(int Length)
  5. generateString(int maxlength)
  6. generateString(String charSet, int len)
  7. generateStrings(int count, int length)
  8. generateStringsEntries(int cnt)
  9. getDummyPassword()