RandomUtil.java 465 Bytes
package com.subsidy.util;

import java.util.Random;

public class RandomUtil {

    public static int getCode() {
        return (int)((Math.random() * 9 + 1) * 100000);
    }

    public static String getRandomCode(int randomLength) {
        StringBuilder str = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < randomLength; i++) {
            str.append(random.nextInt(10));
        }
        return str.toString();
    }
}