Java examples for java.util:Random
get Random URL
//package com.java2s; public class Main { public static String getRandomURL() { return "http://" + getRandomAlphaString(3) + "." + getRandomAlphaString(10) + ".com/" + getRandomAlphaString(getRandomInt(3, 10)); }//from w ww. ja va 2 s . c om public static String getRandomAlphaString(int length) { StringBuilder b = new StringBuilder(); for (int i = 0; i < length; i++) { // ascii 60 to 90 char str = (char) (65 + (int) (Math.random() * (90 - 65))); b.append(str); } return b.toString(); } public static int getRandomInt() { return getRandomInt(1, Integer.MAX_VALUE); } public static int getRandomInt(int min, int max) { return min + (int) ((Math.random() * (max - min))); } }