Java Random String getRandomString()

Here you can find the source of getRandomString()

Description

get Random String

License

Open Source License

Declaration

public static String getRandomString() 

Method Source Code

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

import java.util.*;

public class Main {
    public static String getRandomString() {
        String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        StringBuilder sb = new StringBuilder();
        Random r = new Random();
        while (sb.length() < 12) {
            int index = (int) (r.nextFloat() * chars.length());
            sb.append(chars.charAt(index));
        }//  ww  w. j a  v a 2s  .  c om
        return sb.toString().toLowerCase();
    }
}

Related

  1. getRandomString()
  2. getRandomString()
  3. getRandomString()
  4. getRandomString()
  5. getRandomString()
  6. getRandomString()
  7. getRandomString()
  8. getRandomString()
  9. getRandomString()