Here you can find the source of getRandomString(int length)
public static String getRandomString(int length)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static String getRandomString(int length) { char[] chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; Random random = new Random(); StringBuilder stringBuiler = new StringBuilder(); for (int i = 0; i < length; i++) { stringBuiler.append(chars[Math.abs(random.nextInt()) % 16]); }//from ww w . j av a 2 s .c o m return stringBuiler.toString(); } }