12

I need a java library to read vcard files (vcf).

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
Giorgio Gelardi
  • 993
  • 4
  • 13
  • 29
  • 2
    Stackoverflow is a web site for QUESTIONS. Please rephrase it as a question. Nonetheless, it's not a real question. – guerda Mar 23 '09 at 09:43

8 Answers8

22

ez-vcard supports versions 2.1, 3.0, and 4.0 of the vCard standard, as well as XML-encoded vCards ("xCard" standard), HTML-encoded vCards ("hCard" microformat), and JSON-encoded vCards ("jCard" standard).

https://github.com/mangstadt/ez-vcard

To read a vCard file, use the Ezvcard.parse() method. Then, call the various getter methods on the returned VCard object to retrieve the vCard data fields.

File file = new File("my-vcard.vcf");
VCard vcard = Ezvcard.parse(file).first();
System.out.println("Name: " + vcard.getFormattedName().getValue());
System.out.println("Email: " + vcard.getEmails().get(0).getValue());
Michael
  • 34,873
  • 17
  • 75
  • 109
  • Hey, seems like best .vcf parser so far, but lets say I have .vcf that has email home, email work and email other. Can you please show detailed example of how would I store different types of emails (home, other, work) to String emailHome, emailWork, emailOther? vcard.getEmails().get(0).getValue(); always gives first, but how to know if that is home email or work email or other email? – Marko Niciforovic Jul 01 '13 at 15:20
  • 1
    @Marko Call the "getTypes()" method on each email object to get its list of "type" parameters. You can then check to see if its type is "home" or "work": email.getTypes().contains(EmailTypeParameter.HOME); – Michael Jul 02 '13 at 11:41
  • 3
    +1 active development – kommradHomer Oct 20 '14 at 12:32
8

A search for Java and vcard yields quite a few results.

In particular there's the Mime-Dir-j which is no longer under active development, but may be all you need, and vcard4j which seems to have been dormant for even longer (last release 2003!).

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
8

Cardme seems to be the best vcard library around with active development and there is even a wiki site up.

Check the project homepage.

user2067787
  • 130
  • 8
George
  • 81
  • 1
  • 1
3

Haven't used it yet (about to try it out), but this looks promising.

http://code.google.com/p/android-vcard/

tobinibot
  • 193
  • 1
  • 2
  • 10
1

I found this API that might do the trick: http://sourceforge.net/projects/mime-dir-j/

Mario Ortegón
  • 18,670
  • 17
  • 71
  • 81
0

Try Google, Yahoo, whatever and find http://vcard4j.sourceforge.net/

guerda
  • 23,388
  • 27
  • 97
  • 146
0

Well, just in case you want to use a mobile phone, JSR75 does it right out of the box:

javax.microedition.pim.PIM.fromSerialFormat is specified as supporting vCard 3.0

michael aubert
  • 6,836
  • 1
  • 16
  • 32