Java Random String generateRandomString(Random random, int size)

Here you can find the source of generateRandomString(Random random, int size)

Description

generate Random String

License

Open Source License

Declaration

static String generateRandomString(Random random, int size) 

Method Source Code

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

import java.util.*;

public class Main {
    static String generateRandomString(Random random, int size) {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < size; i++) {
            char letter = (char) ((byte) 'A' + (byte) random.nextInt(26));
            stringBuilder.append(letter);
        }//w  ww. ja va  2  s .c om
        return stringBuilder.toString();
    }
}

Related

  1. generateRandomString(int n)
  2. generateRandomString(int size)
  3. generateRandomString(int stringLength)
  4. generateRandomString(int wordsLength, String separator)
  5. generateRandomString(Random random, int length)
  6. generateRandomString(Random rnd, char[] alphabet, int maxLength)
  7. generateRandomString(String str, int length)
  8. genRandomString()
  9. genRandomString(final int length)