code: private static String getRandomString(int length, char[] chars) throws IllegalArgumentException {
  		if (length < 1)
  			throw new IllegalArgumentException("Invalid length: " + length);
  		
  		if (chars == null || chars.length == 0)
  			throw new IllegalArgumentException("Null/Empty chars");
  		
  		StringBuilder sb = new StringBuilder();
  		Random random = new Random();
  		for (int i = 0; i < length; i++) {
  			char c = chars[random.nextInt(chars.length)];
  			sb.append(c);
  		}
  		return sb.toString();
  	}
docs: Generates a random String
  @param length length of returned string
  @param chars set of chars which will be using during random string generation
  @return a random string with given length.
  @throws IllegalArgumentException if (length &lt; 1 || chars == null || chars.length == 0)