package com.fuyuanshen.web; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class VCardGenerator { 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" }; // 创建.vcf文件 String filename = "shangrao_contacts.vcf"; try (BufferedWriter writer = new BufferedWriter(new FileWriter(filename))) { // 写入文件头 writer.write("BEGIN:VCARD"); writer.newLine(); writer.write("VERSION:3.0"); writer.newLine(); writer.newLine(); // 生成所有联系人 int count = 0; for (String prefix : prefixes) { for (int i = 0; i < 100; i++) { String middle = String.format("%02d", i); String phoneNumber = prefix + middle + "51"; // 写入单个联系人 writer.write("FN:" + phoneNumber); // 姓名字段使用手机号 writer.newLine(); writer.write("TEL;TYPE=CELL:" + phoneNumber); // 电话字段使用手机号 writer.newLine(); writer.write("END:VCARD"); writer.newLine(); writer.newLine(); count++; } } // 写入文件尾 writer.write("END:VCARD"); System.out.println("成功生成 " + count + " 个联系人"); System.out.println("文件已保存为: " + filename); } catch (IOException e) { System.err.println("文件写入错误: " + e.getMessage()); } } }