Java Random String getRandomString(int lenght)

Here you can find the source of getRandomString(int lenght)

Description

get Random String

License

Open Source License

Declaration

public static String getRandomString(int lenght) 

Method Source Code

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

import java.util.Random;

public class Main {
    public static String getRandomString(int lenght) {
        Random rnd = new Random(System.currentTimeMillis());
        String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        StringBuilder b = new StringBuilder();
        for (int i = 0; i < lenght; i++) {
            b.append(alpha.charAt(rnd.nextInt(alpha.length())));
        }/*w  w w.j a  v a2  s  .  c o  m*/
        return b.toString();
    }
}

Related

  1. getRandomString(int len)
  2. getRandomString(int len)
  3. getRandomString(int len)
  4. getRandomString(int len)
  5. getRandomString(int len, boolean ascii_only)
  6. getRandomString(int length)
  7. getRandomString(int length)
  8. getRandomString(int length)
  9. getRandomString(int length)