生成随机数

来源:互联网 发布:apache ant 1.9.7.zip 编辑:程序博客网 时间:2024/06/03 22:55
public String random(String appId){String random = "";int[] array = {0,1,2,3,4,5,6,7,8,9};Random rand = new Random();for (int i = 10; i > 1; i--) {    int index = rand.nextInt(i);    int tmp = array[index];    array[index] = array[i - 1];    array[i - 1] = tmp;}int result = 0;for(int i = 0; i < 8; i++)    result = result * 10 + array[i];String currDate = String.valueOf(System.currentTimeMillis());random = appId.concat(currDate).concat(result+"");return random;}

0 0