0

Lets say I have a vCard text file and I want to get the persons phone number, email address and full name. Whats an easy way to do that without manually skipping text with a scanner or going readLine with a bufferedReader?

BEGIN:VCARD
VERSION:2.1
TEL;PREF;WORK;VOICE;ENCODING=QUOTED-PRINTABLE:(+64 9) 373-7599=20
N:Vaughan;Tim;;Dr;
FN:Dr Tim  Vaughan
ADR;WORK;;ENCODING=QUOTED-PRINTABLE:;Building 303S Room 367;;Auckland;;Private Bag 92019 Auckland;New Zealand
TITLE:Research Fellow
EMAIL;INTERNET:xxx@gmail.com
ORG:University of Auckland;Department of Computer Science
URL;WORK:
REV:2013-09-12T15:06:11Z
END:VCARD
Tal Zamirly
  • 117
  • 1
  • 11
  • 1
    `BufferedReader` and `readline` if you want to do it yourself or a [`VCard`](https://code.google.com/p/ez-vcard/) library if you don't... – MadProgrammer Sep 12 '13 at 03:11
  • 1
    You could use an existing library: http://stackoverflow.com/questions/672704/where-to-find-a-java-library-to-read-vcard-files –  Sep 12 '13 at 03:25

1 Answers1

0

You can use an external library like ez-vcard. And then access the as VCard elements below

FileInputStream fin = ...;
    Vcard contacts = Ezvcard.parse(fin).all();
    for(VCard myCard : contacts){
        System.out.println("Contact In the Phonebook \n" + "\t"
                + myCard.getFormattedName().getValue()
                + "\n\t" + myCard.getEmails().get(0).getValue()
                + "\n\t" + myCard.getTelephoneNumbers().get(0).getText());
    }
brizzy_p
  • 301
  • 3
  • 7