Java Password Generate generateString(int length)

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

Description

generate String

License

Apache License

Declaration

public static String generateString(int length) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    private final static String alphabet = "abcdefghijklmnopqrstuvwxyz1234567890";
    private final static Random random = new Random();

    public static String generateString(int length) {
        StringBuilder sb = new StringBuilder();
        for (int k = 0; k < length; k++) {
            char c = alphabet.charAt(random.nextInt(alphabet.length()));
            sb.append(c);/*w w w  .ja v  a2 s  .  c o  m*/
        }

        return sb.toString();
    }
}

Related

  1. generatePassword(int length, boolean special)
  2. generatePassword(int length, String combination)
  3. generatePassword(int minLen, int maxLen, int noOfCAPSAlpha, int noOfDigits, int noOfSplChars)
  4. generateString(final String letters, int length)
  5. generateString(int length)
  6. generateString(int length)
  7. generateString(int length)
  8. GenerateString(int Length)
  9. generateString(int maxlength)