Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8437103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:20:40+00:00 2026-06-10T07:20:40+00:00

I am using cardme library to deal with vcards. Following is my code package

  • 0

I am using cardme library to deal with vcards. Following is my code

package vcardtest;

import java.io.*;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sourceforge.cardme.engine.VCardEngine;
import net.sourceforge.cardme.vcard.VCard;
import net.sourceforge.cardme.vcard.features.EmailFeature;
import net.sourceforge.cardme.vcard.features.NameFeature;
import net.sourceforge.cardme.vcard.features.NicknameFeature;
import net.sourceforge.cardme.vcard.features.TelephoneFeature;
import net.sourceforge.cardme.vcard.types.parameters.TelephoneParameterType;

public class VCardTest 
{

    public static void main(String[] args) 
    {
        File vcardFile = new File("C:/Users/yohan/Contacts/Yohan Weerasinghe.vcf");
        VCardEngine vcardEngine = new VCardEngine();
        try 
        {
            VCard vcard = vcardEngine.parse(vcardFile);
            String name = vcard.getName().getGivenName();

            EmailFeature email = vcard.getEmails().next();
            String sEmail = email.getEmail();

            NicknameFeature nickName = vcard.getNicknames();
            Iterator<String> nicknames = nickName.getNicknames();
            String sNickName = nicknames.next();

            Iterator<TelephoneFeature> telephoneNumbers = vcard.getTelephoneNumbers();
            TelephoneFeature next = telephoneNumbers.next();

            String telephone = "";


                while(vcard.getTelephoneNumbers().hasNext())
                {
                    TelephoneFeature next1 = vcard.getTelephoneNumbers().next();
                    telephone = next1.getTelephone();



                    System.out.println(telephone);
                }



            Iterator<TelephoneParameterType> telephoneParameterTypes = next.getTelephoneParameterTypes();
            TelephoneParameterType next1 = telephoneParameterTypes.next();
            String type = next1.getType();

            TelephoneParameterType next2 = telephoneParameterTypes.next();
            String type2 = next2.getType();


            System.out.println( name );
            System.out.println(sEmail);
            System.out.println(sNickName);

            System.out.println(type);
            System.out.println(type2);


        } catch (IOException ex) 
        {
           ex.printStackTrace();
        }
    }
}

However, there is no method called getNumber() or something. How can I get the mobile numbers and land numbers? Please help!

NOTE: I UPDATED THE CODE. In there, you can see I managed to get the phone number. But, this returns only the HOME phone and not anything else. Even the loop is not stopping. Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:20:41+00:00Added an answer on June 10, 2026 at 7:20 am

    I can see

    TelephoneFeature.getTelephone()
    

    I’d also suggest taking a look at

    TelephoneFeature.getTelephoneParameterTypes()
    

    to see the types

    UPDATE

    Be careful with the iterators

    Each call to vcard.getTelephoneNumbers() is creating a new Iterator, which means you could end up in an infinite loop.

    Iterator<TelephoneFeature> itNumbers = vcard.getTelephoneNumbers();
    while (itNumbers.hasNext()) {
    
        TelephoneFeature next1 = itNumbers.next();
        String telephone = next1.getTelephone();
    
        System.out.println(telephone);
        System.out.println("types = " + next1.getExtendedTelephoneParameterSize());
    
        Iterator<XTelephoneParameterType> itTypes = next1.getExtendedTelephoneParameterTypes();
        while (itTypes.hasNext()) {
    
            XTelephoneParameterType next = itTypes.next();
            System.out.println(" - " + next.getType() + " / " + next.getDescription());
    
        }
    
    }
    

    I stand corrected, the problem (isn’t a bug) it’s with the tester, not the API 😛

    If you add

    Iterator<TelephoneParameterType> itNTypes = next1.getTelephoneParameterTypes();
    while (itNTypes .hasNext()) {
    
        TelephoneParameterType next = itNTypes .next();
        System.out.println(" - " + next.getType() + " / " + next.getDescription());
    
    }
    

    to the previous loop, you should get what you’re looking for

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
Hi I am trying to create a vcard (.vcf) file in Java using Cardme
using Silverlight I am having trouble with the following code: CultureInfo culture = new
Using import datetime in python, is it possible to take a formatted time/date string
Using Java,I have to fetch multiple sets of values from an XML file to
Using EF Code First I have an model object that has multiple properties that
Using Google Maps InfoBox - http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html Currently the map will scroll - pan control
Using ASP.Net and VB.Net Code Image1.ImageUrl = c:\Blue hills.jpg The above code is not
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
Using the Exiv2 library to write some exif tags to an image i'm running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.