Java Random generateRandom(Integer bitNum)

Here you can find the source of generateRandom(Integer bitNum)

Description

generate Random

License

Apache License

Declaration

public static String generateRandom(Integer bitNum) 

Method Source Code

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

import java.util.*;

public class Main {
    public static String generateRandom(Integer bitNum) {
        if (bitNum == null) {
            bitNum = 32;/*from   w  ww  .j  a  v  a2  s  . c o  m*/
        }
        String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < bitNum; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }
}

Related

  1. extractRandomObject(Collection c)
  2. extractRandomVector(Collection c, int newSize)
  3. gaussianInt(Random random, int min, int max)
  4. generateRandom(byte[] byteArray)
  5. generateRandom(int length, int type)
  6. generateRandomIntegerId()
  7. generateRandomNo()
  8. GenerateRandomPin()
  9. getItemID(Random r)