使用gbk字库,减少生僻字
import ;
/**
* Created on 2020-10-02
*/
public class GenerateName {
public static void main(String[] args) {
printName("韩", 2, 800);
}
/**
* 打印名字
* @param lastName 姓
* @param digits 名字长度
* @param count 生成数量
*/
public static void printName(String lastName, int digits, int count) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < count; i++) {
if (i % 10 == 0) {
("\n");
}
(lastName);
(getRandom(digits));
(" ");
}
(());
}
@SuppressWarnings("checkstyle:MagicNumber")
public static String getRandom(int len) {
String ret = "";
for (int i = 0; i < len; i++) {
String str = null;
int hightPos, lowPos;
Random random = new Random();
hightPos = (176 + ((39)));
lowPos = (161 + ((93)));
byte[] b = new byte[2];
b[0] = (new Integer(hightPos).byteValue());
b[1] = (new Integer(lowPos).byteValue());
try {
str = new String(b, "GBK");
} catch (Exception e) {
(e);
}
ret += str;
}
return ret;
}
}