Java Random String generateRandomString(int len)

Here you can find the source of generateRandomString(int len)

Description

generate Random String

License

Open Source License

Declaration

public static String generateRandomString(int len) 

Method Source Code

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

import java.util.Random;

public class Main {
    static final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    public static Random random = new Random();

    public static String generateRandomString(int len) {
        StringBuilder sb = new StringBuilder(len);
        for (int i = 0; i < len; i++)
            sb.append(AB.charAt(random.nextInt(AB.length())));
        return sb.toString();
    }//from  ww w.  j  av  a 2  s.c om
}

Related

  1. generateRandomString()
  2. generateRandomString()
  3. generateRandomString(final int minCharLen, final int maxCharLen)
  4. generateRandomString(final String pattern)
  5. generateRandomString(int count)
  6. generateRandomString(int length)
  7. generateRandomString(int length)
  8. generateRandomString(int length)
  9. generateRandomString(int length)