Files
fys-Multi-tenant/fys-admin/src/main/java/com/fuyuanshen/web/PhoneNumberGenerator.java
2025-08-13 19:29:04 +08:00

41 lines
1.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.fuyuanshen.web;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class PhoneNumberGenerator {
public static void main(String[] args) {
// 定义江西上饶的134号段共22个
String[] prefixes = {
"1340703", "1340793", "1342650", "1342651", "1342663",
"1342664", "1342665", "1343703", "1343793", "1347901",
"1347902", "1347903", "1347930", "1347931", "1347932",
"1347933", "1347934", "1347935", "1347936", "1347937",
"1347938", "1347939"
};
// 输出到控制台
System.out.println("江西上饶134号段完整手机号码共2200个");
for (String prefix : prefixes) {
for (int i = 0; i < 100; i++) {
String middle = String.format("%02d", i); // 生成00-99的中间数字
System.out.println(prefix + middle + "51");
}
}
// 同时输出到文件(可选)
try (BufferedWriter writer = new BufferedWriter(new FileWriter("shangrao_phones.txt"))) {
for (String prefix : prefixes) {
for (int i = 0; i < 100; i++) {
String middle = String.format("%02d", i);
writer.write(prefix + middle + "51");
writer.newLine();
}
}
System.out.println("\n同时已保存到文件shangrao_phones.txt");
} catch (IOException e) {
System.err.println("文件写入错误:" + e.getMessage());
}
}
}