Java Random String randomString(int stringLength)

Here you can find the source of randomString(int stringLength)

Description

random String

License

Apache License

Declaration

static String randomString(int stringLength) 

Method Source Code

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

import java.util.*;

public class Main {
    static String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static Random rand = new Random(0);

    static String randomString(int stringLength) {
        StringBuffer s = new StringBuffer();
        for (int i = 0; i < stringLength; i++) {
            int c = rand.nextInt(26);
            s.append(alphabet.charAt(c));
        }//from  w  w  w  . ja va  2s. c  o m
        return s.toString();
    }
}

Related

  1. randomString(int length)
  2. randomString(int length)
  3. randomString(int length)
  4. randomString(int length)
  5. randomstring(int lo, int hi)
  6. randomString(Integer len)
  7. randomString(Random r, int minCount, int maxCount)
  8. randomSubset(String[] list, int count)
  9. randomSuffix(final String name)