Java Random String generateRandomString(int length)

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

Description

generate Random String

License

Apache License

Declaration

public static String generateRandomString(int length) 

Method Source Code

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

import java.util.Random;

public class Main {
    public static String generateRandomString(int length) {
        StringBuilder str = new StringBuilder();
        String base = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        Random rnd = new Random();
        for (int i = 0; i < length; i++) {
            str.append(base.charAt(rnd.nextInt(base.length())));
        }//from w w  w.  j  a  va 2s.c om
        return str.toString();
    }
}

Related

  1. generateRandomString(int count)
  2. generateRandomString(int len)
  3. generateRandomString(int length)
  4. generateRandomString(int length)
  5. generateRandomString(int length)
  6. generateRandomString(int length)
  7. generateRandomString(int length)
  8. generateRandomString(int length)
  9. generateRandomString(int length)