首页 > 其他分享 >随机字符串

随机字符串

时间:2022-09-27 15:34:10浏览次数:50  
标签:count int chars 随机 字符串 长度

使用了org.apache.commons.lang包下的工具类
RandomStringUtils

引入依赖

<dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>

如下列出几个比较常用的方法
random(int count) 生成一个长度为count的字符串,随机内容包含全部的编码。

randomAscii(int count) 生成一个长度为count的字符串,随机内容仅包含Ascii编码。

randomAlphabetic(int count) 生成一个长度为count的字符串,随机内容包含字母(含大小)的编码。

randomAlphanumeric(int count) 生成一个长度为count的字符串,随机内容包含字母(含大小)数字(0~9)的编码。 // 这个用的最多,有大小写,有字母

randomNumeric(int count) 生成一个长度为count的字符串,随机内容包含数字(0~9)的编码。

random(int count, char[] chars) 生成一个长度为count的字符串,随机内容包含chars。

random(int count, String chars) 生成一个长度为count的字符串,随机内容包含chars。

标签:count,int,chars,随机,字符串,长度
From: https://www.cnblogs.com/PythonOrg/p/16734722.html

相关文章