举个例子,用电子表格生成csv文件,并导入到C:\Users\***\Contacts目录下,然后再导出成为vcf文件,到目前为止,文件还没有生成我们最终想要的文件,还是一个个单个的文件,还需要再来一步,合并文件成为一个
copy /B *.vcf all.vcf
费时费力,我的电脑,导入一万多条cvs到电脑里面用了4个小时都没有完成,最后结束导入,结果电脑就这样了,内存溢出???
还说什么导出vcf给手机呢,
最后,我为什么不直接一步到位呢,然后就有了以下的代码,
直接打开单个vcf文件和多合一文件的vcf文件,就发现了一个规律
BEGIN:VCARD
END:VCARD
结尾,灵光一闪就出了这个,按照自己的想法,写出了下面的代码,一下仅仅是JAVA的,有谁可以改成C++,才是真的好,现在我也没有余力再次学习C++的了,
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
System.out.println("This is a phone number generator");
BufferedWriter bfw = new BufferedWriter(new FileWriter("/dev/shm/OutPut.vcf"));
System.out.println("请输入手机号码前缀:");
Scanner sc = new Scanner(System.in);
String prefix = sc.next();
System.out.println("请输入手机号码后缀:");
String postfix = sc.next();
int length = 11 - prefix.length() - postfix.length();
System.out.println("需要补全" + length + "位");
if (length>0){
extracted(bfw, prefix, postfix, length);
}else {
System.out.println("输入异常8888");
}
}
private static void extracted(BufferedWriter bfw, String prefix, String postfix, int length) throws IOException {
int pow = (int) Math.pow(10, length);
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < pow; i++) {
String loopString = i + "";
int loopLength = (i + "").length();
if (loopLength != length) {
int k = length - loopLength;
String s = "";
for (int j = 0; j < k; j++) {
s = "0" + s;
}
loopString = s + loopString;
}
list.add(loopString);
System.out.println(loopString);
}
for (int i = 0; i < list.size(); i++) {
bfw.write("BEGIN:VCARD");
bfw.newLine();
bfw.write("VERSION:2.1");
bfw.newLine();
bfw.write("N:;" + list.get(i));
bfw.newLine();
bfw.write("FN:" + list.get(i));
bfw.newLine();
bfw.write("TEL;CELL;VOICE:" + prefix + list.get(i) + postfix);
bfw.newLine();
bfw.write("REV:20210923T021744Z");
bfw.newLine();
bfw.write("END:VCARD");
bfw.newLine();
}
bfw.close();
System.out.println("Ok");
}
}
//BEGIN:VCARD
//VERSION:2.1
//N:;830000
//FN:830000
//TEL;CELL;VOICE:18983000048
//REV:20210923T021744Z
//END:VCARD