Java 生成随机数据

文章目录

1. Java-faker

依赖

xml 复制代码
<dependency>
    <groupId>com.github.javafaker</groupId>
    <artifactId>javafaker</artifactId>
    <version>1.0.2</version>
</dependency>

https://github.com/HannnnXiao/javafaker

demo

java 复制代码
		Faker faker = new Faker(Locale.CHINA); //指定地区
        final Name name = faker.name();
        System.out.println("firstName : " + name.firstName());
        System.out.println("username : " + name.username());
        System.out.println("bloodGroup : " + name.bloodGroup());
        System.out.println("suffix : " + name.suffix());
        System.out.println("title : " + name.title());
        System.out.println("lastName : " + name.lastName());
        System.out.println("nameWithMiddle : " + name.nameWithMiddle());
        System.out.println("fullName : " + name.fullName());
        System.out.println("name : " + name.name());
        System.out.println("prefix : " + name.prefix());
java 复制代码
生成结果

firstName : 熠彤
username : 烨霖.龙
bloodGroup : A-
suffix : IV
title : Investor Division Engineer
lastName : 范
nameWithMiddle : 胡思
fullName : 孟鸿涛
name : 黎航
prefix : Miss

2. common-random

依赖

xml 复制代码
<dependency>
    <groupId>com.apifan.common</groupId>
    <artifactId>common-random</artifactId>
    <version>1.0.21</version>
</dependency>

https://github.com/yindz/common-random

demo

java 复制代码
统一入口
//地区类虚拟数据
AreaSource areaSource = RandomSource.areaSource();

//日期时间类虚拟数据
DateTimeSource dateTimeSource = RandomSource.dateTimeSource();

//教育类虚拟数据
EducationSource educationSource = RandomSource.educationSource();

//金融类虚拟数据
FinancialSource financialSource = RandomSource.financialSource();

//互联网信息类虚拟数据
InternetSource internetSource = RandomSource.internetSource();

//数字类虚拟数据
NumberSource numberSource = RandomSource.numberSource();

//个人类虚拟数据
PersonInfoSource personInfoSource = RandomSource.personInfoSource();

//体育竞技类虚拟数据
SportSource sportSource = RandomSource.sportSource();

//语言文字类虚拟数据
LanguageSource languageSource = RandomSource.languageSource();

//其它杂项虚拟数据
OtherSource otherSource = RandomSource.otherSource();
相关推荐
笨拙的老猴子4 分钟前
[特殊字符] Java GC机制详解:G1、ZGC、Shenandoah全面解析与版本演进对比
java·开发语言
水木流年追梦6 分钟前
大模型入门-Reward 奖励模型训练
开发语言·python·算法·leetcode·正则表达式
电子云与长程纠缠28 分钟前
UE5制作六边形包裹球体效果
开发语言·python·ue5
砍材农夫34 分钟前
物联网 基于netty构建mqtt协议规范(遗嘱与保留消息)
java·开发语言·物联网·netty
DFT计算杂谈37 分钟前
KPROJ编译教程
java·前端·python·算法·conda
重生之我是Java开发战士1 小时前
【笔试强训】Week5:空调遥控, kotor和气球,走迷宫,主持人调度II,体操队形,二叉树的最大路径和,排序子序列,消减整数
java·算法·动态规划
froginwe111 小时前
Python3 迭代器与生成器
开发语言
xiaoshuaishuai81 小时前
C# 签名异常与Gas预估失败调试方案
开发语言·网络·tcp/ip·c#
xiaoshuaishuai81 小时前
C# Gemini 辅助网络安全漏洞分析
开发语言·web安全·c#
念恒123061 小时前
Python(循环中断)
开发语言·python