3
안녕 Cardme API를 사용하여 Java에서 vcard (.vcf) 파일을 만들려고합니다. .vcf 파일을 저장할 수는 있지만 내용이없고 비어 있습니다. Cardme를 사용하여 VCard 만들기 Java
private void generateVCard(Card card){
HelperClass helper = new HelperClass();
VCardImpl vcard = new VCardImpl();
BeginFeature begin = new BeginFeatureImpl();
vcard.setBegin(begin);
vcard.addEmail(helper.formEmailFeature(card));
vcard.addAddress(helper.formAddress(card));
vcard.addPhoto(helper.formPhotoFeature(card));
vcard.addTelephoneNumber(helper.formTelephoneFeature(card));
vcard.setName(helper.formNameFeature(card));
vcard.setFormattedName(helper.formattedName(card));
saveToFile("vc.vcf",vcard);
}
/**
* This function saves a VCard to disk.
*/
public void saveToFile(String fileName , VCard vcard) {
Writer output = null;
File file = new File("fileName");
try {
output = new BufferedWriter(new FileWriter(file));
output.write(vcard.toString());
output.flush();
output.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
이 문제 해결에 어떤 도움을 주셔서 감사합니다, 아래에있는 내 코드를 검색 할 수 있습니다.
import info.ineighborhood.cardme.io.VCardWriter;
또는 라이브러리 (v0.3.3) 패키지는 최신 버전 :
import net.sourceforge.cardme.io.VCardWriter;
한 다음 사용
공중 전화 번호 양식 텔레폰 기능 (카드 카드) { \t \t TelephoneFeature telephoneFeature = new TelephoneFeatureImpl(); \t \t telephoneFeature.setTelephone (card.getContact(). getHmePhn()); \t \t return telephoneFeature; \t} – jshree
정확히 무엇을해야할지 모르십니까? 위 코드 블록은 VCard 출력을 파일에 저장합니다. – Femi
죄송합니다. 마지막 코멘트를 완전히 작성하지 않았습니다. 나는 당신의 해결책을 시도했다. formTelephoneFeature() method.Exception을 "main"스레드에서 사용할 때 다음 오류가 발생합니다. info.ineighborhood.cardme.vcard.errors.VCardBuildException : TelephoneFeature (TEL) [info.ineighborhood.cardme.vcard.errors.VCardBuildException ] TelephoneFeature (TEL)가 있지만 비어 있습니다. – jshree