当前位置:网站首页>[Commons lang3 topic] 003- randomstringutils topic
[Commons lang3 topic] 003- randomstringutils topic
2022-07-29 00:58:00 【Zibo Zibo】
【commons-lang3 project 】003- RandomStringUtils project
List of articles
- 【commons-lang3 project 】003- RandomStringUtils project
- 〇、 Get ready
- One 、 Random string
- 1、 Generates a random string of the specified length ( All character sets except alphanumeric )
- 2、 Generates a random string of the specified length ( Specify character set )
- 3、 Generate a random string of the specified length from the specified character set array
- 4、 Generate a string of specified length from the specified character set
- Two 、 Random alphabetic string
- 3、 ... and 、 Random number string
- Four 、 Random alphabetic or numeric string
- 5、 ... and 、 Random ASCII Code string
- 6、 ... and 、 Random string - Regular matching set
- 7、 ... and 、 Complete code
〇、 Get ready
1、RandomStringUtils The main role
Provide and generate various Random string Method .
2、 Introduce dependencies
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
One 、 Random string
1、 Generates a random string of the specified length ( All character sets except alphanumeric )
// 1、 Generates a random string of the specified length ( All character sets except alphanumeric )
// Select characters from all character sets , Excluding letters and numbers
System.out.println(RandomStringUtils.random(5)); // 𥘿𦊿 Way
2、 Generates a random string of the specified length ( Specify character set )
// 2、 Generates a random string of the specified length ( Specify character set )
// grammar :random(int count, boolean letters, boolean numbers)
// letters: Alphabetic character set numbers: Digital character set
// Random strings consist of letters and numbers
System.out.println(RandomStringUtils.random(5, true, true)); // ny6Oh
// Random strings consist of letters
System.out.println(RandomStringUtils.random(5, true, false)); // edrYz
// Random strings consist of numbers
System.out.println(RandomStringUtils.random(5, false, true)); // edrYz
// A random string consists of all character sets except alphanumeric ( Equate to random(int count))
System.out.println(RandomStringUtils.random(5, false, false)); // ᷉줅𝥛뚣
3、 Generate a random string of the specified length from the specified character set array
// 3、 Generate a random string of the specified length from the specified character set array
System.out.println(RandomStringUtils.random(5, 'A', 'B', '1', '2')); // 2B21B
4、 Generate a string of specified length from the specified character set
// 4、 Generate a string of specified length from the specified character set
System.out.println(RandomStringUtils.random(5, "bkjfsdhjkkj32h54386tweuyfb345")); // 3u4e4
Two 、 Random alphabetic string
5、 Generate a random letter string of specified length
// 5、 Generate a random letter string of specified length
// amount to random(count, true, false)
System.out.println(RandomStringUtils.randomAlphabetic(5)); // yaalN
6、 Generate a random letter string between two lengths
// 6、 Generate a random letter string between two lengths
System.out.println(RandomStringUtils.randomAlphabetic(5, 10)); // uuIpdckTS
3、 ... and 、 Random number string
7、 Generate a random number string of specified length
// 13、 Generate a random number string of specified length
System.out.println(RandomStringUtils.randomNumeric(5)); // 56789
8、 Generate a random number string between two lengths
// 14、 Generate a random number string between two lengths
System.out.println(RandomStringUtils.randomNumeric(8, 16)); // 81179252
Four 、 Random alphabetic or numeric string
9、 Generate a random letter or number string of specified length
// 7、 Generate a random letter or number string of specified length
// amount to random(count, true, true)
System.out.println(RandomStringUtils.randomAlphanumeric(5)); // n91KB
10、 Generate a random letter or number string between two lengths
// 8、 Generate a random letter or number string between two lengths
System.out.println(RandomStringUtils.randomAlphanumeric(5, 10)); // vs5cw8Q
5、 ... and 、 Random ASCII Code string
11、 Generates a random of a specified length ASCII Code string
// 9、 Generates a random of a specified length ASCII Code string
// ASCII Code value between [32,126] Between , amount to random(count, 32, 127, false, false)
System.out.println(RandomStringUtils.randomAscii(5)); // 7*>/#
12、 Generate random between two lengths ASCII Code string
// 10、 Generate random between two lengths ASCII Code string
System.out.println(RandomStringUtils.randomAscii(8, 16)); // ;TD/+kHB2n$Dg
13、 Generate visible random of specified length ASCII Code string
// 11、 Generate visible random of specified length ASCII Code string
// That is, anything except spaces and control characters , amount to random(count, 33, 126, false, false)
System.out.println(RandomStringUtils.randomGraph(5)); // ")N$R
14、 Generate visible random between two lengths ASCII Code string
// 12、 Generate visible random between two lengths ASCII Code string
System.out.println(RandomStringUtils.randomGraph(8, 16)); // *?'u{iDDN=#{b&T
6、 ... and 、 Random string - Regular matching set
15、 Generates a random string of the specified length ( Character set matched from regular expression character class )
// 15、 Generates a random string of the specified length ( Character set matched from regular expression character class )
// Select characters from the character set matched by the regular expression character class , No spaces and control characters
System.out.println(RandomStringUtils.randomPrint(5)); // L*bh1
16、 Generate a random string between two lengths ( Character set matched from regular expression character class )
// 16、 Generate a random string between two lengths ( Character set matched from regular expression character class )
// Select characters from the character set matched by the regular expression character class , No spaces and control characters
System.out.println(RandomStringUtils.randomPrint(8, 16)); // 4D-.4V\ZH
7、 ... and 、 Complete code
package com.zibo.zibo2022.random_string_utils.main;
import org.apache.commons.lang3.RandomStringUtils;
public class Main {
public static void main(String[] args) {
// start
// 1、 Generates a random string of the specified length ( All character sets except alphanumeric )
// Select characters from all character sets , Excluding letters and numbers
System.out.println(RandomStringUtils.random(5)); // 𥘿𦊿 Way
// 2、 Generates a random string of the specified length ( Specify character set )
// grammar :random(int count, boolean letters, boolean numbers)
// letters: Alphabetic character set numbers: Digital character set
// Random strings consist of letters and numbers
System.out.println(RandomStringUtils.random(5, true, true)); // ny6Oh
// Random strings consist of letters
System.out.println(RandomStringUtils.random(5, true, false)); // edrYz
// Random strings consist of numbers
System.out.println(RandomStringUtils.random(5, false, true)); // edrYz
// A random string consists of all character sets except alphanumeric ( Equate to random(int count))
System.out.println(RandomStringUtils.random(5, false, false)); // ᷉줅𝥛뚣
// 3、 Generate a random string of the specified length from the specified character set array
System.out.println(RandomStringUtils.random(5, 'A', 'B', '1', '2')); // 2B21B
// 4、 Generate a string of specified length from the specified character set
System.out.println(RandomStringUtils.random(5, "bkjfsdhjkkj32h54386tweuyfb345")); // 3u4e4
// 5、 Generate a random letter string of specified length
// amount to random(count, true, false)
System.out.println(RandomStringUtils.randomAlphabetic(5)); // yaalN
// 6、 Generate a random letter string between two lengths
System.out.println(RandomStringUtils.randomAlphabetic(5, 10)); // uuIpdckTS
// 7、 Generate a random letter or number string of specified length
// amount to random(count, true, true)
System.out.println(RandomStringUtils.randomAlphanumeric(5)); // n91KB
// 8、 Generate a random letter or number string between two lengths
System.out.println(RandomStringUtils.randomAlphanumeric(5, 10)); // vs5cw8Q
// 9、 Generates a random of a specified length ASCII Code string
// ASCII Code value between [32,126] Between , amount to random(count, 32, 127, false, false)
System.out.println(RandomStringUtils.randomAscii(5)); // 7*>/#
// 10、 Generate random between two lengths ASCII Code string
System.out.println(RandomStringUtils.randomAscii(8, 16)); // ;TD/+kHB2n$Dg
// 11、 Generate visible random of specified length ASCII Code string
// That is, anything except spaces and control characters , amount to random(count, 33, 126, false, false)
System.out.println(RandomStringUtils.randomGraph(5)); // ")N$R
// 12、 Generate visible random between two lengths ASCII Code string
System.out.println(RandomStringUtils.randomGraph(8, 16)); // *?'u{iDDN=#{b&T
// 13、 Generate a random number string of specified length
System.out.println(RandomStringUtils.randomNumeric(5)); // 56789
// 14、 Generate a random number string between two lengths
System.out.println(RandomStringUtils.randomNumeric(8, 16)); // 81179252
// 15、 Generates a random string of the specified length ( Character set matched from regular expression character class )
// Select characters from the character set matched by the regular expression character class , No spaces and control characters
System.out.println(RandomStringUtils.randomPrint(5)); // L*bh1
// 16、 Generate a random string between two lengths ( Character set matched from regular expression character class )
// Select characters from the character set matched by the regular expression character class , No spaces and control characters
System.out.println(RandomStringUtils.randomPrint(8, 16)); // 4D-.4V\ZH
// end
}
}
边栏推荐
- UE4 common printing information methods for debugging
- What opportunities does the London gold real-time market bring?
- SQL server only has database files and no log files. The solution to the 1813 error in restoring data times
- Techo hub Fuzhou Station dry goods attack | talk with developers about new industrial intelligence technology
- Error reporting: when the browser clicks the modify add button, there is no response and no error reporting. Solution
- Rk3399 9.0 driver add powser button
- Station B "crashed" from beginning to end 2021.07.13 we collapsed like this (Reprint)
- Necessary interview skills for Android (including interview questions and learning materials)
- 【commons-lang3专题】005- ObjectUtils 专题
- 云函数实现网站自动化签到配置详解【Web函数/Nodejs/cookie】
猜你喜欢

Wechat campus bathroom reservation applet graduation design finished product (5) assignment

如何在WordPress中创建一个自定义404错误页面

Api 接口优化的那些技巧

Method of converting inline elements to block elements

Outlier detection and open set identification (1)

Hash table~

第二轮1000个Okaleido Tiger,再次登录Binance NFT 1小时售罄

Necessary interview skills for Android (including interview questions and learning materials)

如何给女友讲明白JS的bind模拟实现

Xinchi technology released the latest flagship product of G9 series, equipped with six A55 cores with 1.8GHz dominant frequency
随机推荐
【commons-lang3专题】002- RandomUtils 专题
CUDA相关
selenium对接代理与seleniumwire访问开发者工具NetWork
深度学习 | MATLAB实现TCN时间卷积神经网络spatialDropoutLayer参数描述
Talk about the cross end technical scheme
SQL Server 只有数据库文件,没有日志文件,恢复数据时报1813错误的解决方案
Implement Lmax disruptor queue from scratch (VI) analysis of the principle of disruptor solving pseudo sharing and consumers' elegant stopping
ZABBIX deployment and monitoring
新一代超安全蜂窝电池,思皓爱跑上市,13.99万起售
将Word中的表格以图片形式复制到微信发送
靠云业务独撑收入增长大梁,微软仍然被高估?
自制 | 纯手工自制一个16位RISC架构CPU
Anomaly detection and unsupervised learning (2)
[AD learning] the course of PCB drawing in this marine vehicle competition
iNFTnews | 元宇宙购物体验将成为吸引消费者的一大利器
About 1931cie -- conversion of XYZ color coordinate graph to RGB color coordinate relationship
第二轮1000个Okaleido Tiger,再次登录Binance NFT 1小时售罄
MySQL的隔离级别、可能出现的问题(脏读、不可重复读、幻读)及其解决方法
Hash table~
What are the methods to track the real-time market of London Silver?