RandomStringUtils.java 671 Bytes
package com.example.utils;

import java.util.UUID;

/**
 * Created by Administrator on 2017/4/20.
 */
public class RandomStringUtils extends org.apache.commons.lang3.RandomStringUtils {

    public static final String ARTICLE_KEY_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

    public static String getString() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    /**
     * 根据字母表生成指定位数随机字符串
     *
     * @param length 随机长度
     * @return 随机字符串
     */
    public static String getString(int length) {
        return random(length, ARTICLE_KEY_ALPHABET);
    }

}