/*
    生成4位随机数字+字母
    *
    @param length
    * @return 随机码
    */
    public static String getStringRandom(int length) {
    String val = “”;
    Random random = new Random();

    // 参数length,表示生成几位随机数
    for (int i = 0; i < length; i++) {

    1. String charOrNum = random.nextInt(2) % 2 == 0 ? **"char" **: **"num"**;<br /> _// 输出字母还是数字<br /> _**if **(**"char"**.equalsIgnoreCase(charOrNum)) {<br /> _// 输出是大写字母还是小写字母<br /> _**int **temp = random.nextInt(2) % 2 == 0 ? 65 : 97;<br /> **int **n = (**char**) (random.nextInt(26) + temp);<br /> **if**(n == 111 || n == 108 || n == 105 || n == 79){_//不要 l 和 o,i,O<br /> _n++;<br /> }<br /> val += (**char**)n;<br /> } **else if **(**"num"**.equalsIgnoreCase(charOrNum)) {<br /> **int **n = random.nextInt(10);<br /> **if**(n == 0 || n == 1){_//不要0 和 1<br /> _n += 2;<br /> }<br /> val +=String._valueOf_(n);<br /> }<br /> }<br /> **return **val;<br />}<br />_//获取唯一id<br />_**public static **String getId(){<br /> **return **(**new **Date()).getTime()+**""**+(**int**)((Math._random_()*9+1)*100000);<br />}