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

  • Home
  • SEARCH
  • 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 6225623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:52:34+00:00 2026-05-24T08:52:34+00:00

Need help to perform merge two similar contact values. I would like to know

  • 0

Need help to perform merge two similar contact values.
I would like to know how can i merge two similar contact values into a single contact before I convert it as a xml file using Java.
In my case I have contacts like this:

Contact No1:
Contact
Arun
Arun_niit
nuraaa_iceee@yahoo.co.in
Contact
Contact No2:
Contact
Arun
Arun_niit
nuraaa_iceee@gmail.com
Contact

Contact No1&2 has same name and also the contact No 3&4

Contact No3:
Contact
Rangarajkarthik
karthik Rangaraj
kart26@gmail.com
karthikranga@yahoo.com
Contact


Contact No4:
Contact
Rangaraj
karthik 
kart26@gmail.com
karthikranga@yahoo.com
Contact

The above contact repeating twice with the same name and email address. How can I merge this as a single contact?

This is my .partf file and I want to convert this to an XML file which I did. But I want to merge these contacts and then create a XML using my JavaCode.

Contact
Arun
Arun_niit
nuraaa_iceee@yahoo.co.in
Contact
Contact
ColomboGiorgia
Giorgia Colombo
giorgiacolombo81239@libero.it
Contact
Contact
Arun
Arun_niit
nuraaa_iceee@gmail.com
Contact
Contact
KumarVeera
Veera Kumar
KUMARg_8111@yahoo.com
Contact
Contact
MarbellaFunkybuddha
Funkybuddha Marbella
http://www.facebook.com/profile.php?id=1123301493096451
Contact
Contact
Rangarajkarthik
karthik Rangaraj
kart2006@gmail.com
karthikrangaraj@yahoo.com
Contact
Contact
Rangaraj
karthik 
kart26@gmail.com
karthikranga@yahoo.com
Contact

My JavaCode:

package textparser;  
import java.io.BufferedReader;
  import java.io.FileOutputStream;
  import java.io.FileReader;
  import java.util.regex.Pattern;
  import org.xml.sax.ContentHandler;
  import java.io.Serializable;
  import com.sun.org.apache.xml.internal.serialize.OutputFormat;
  import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
  import com.sun.xml.internal.bind.util.AttributesImpl;
  public class Item  {
  public static void main (String args[]) {
  Item.readWrite("D:/Demo/test.part","D:/Demo/juin202.xml");//Read XML and Save as a XML file.
  }

  public static void readWrite(String fromFile, String toFile)  
  {
try{
    Pattern p = Pattern.compile(".+@.+\\.[a-z]+");//A compiled representation of a regular expression. 
    BufferedReader in = new BufferedReader(new FileReader(fromFile));
    FileOutputStream fos = new FileOutputStream(toFile);
    OutputFormat of = new OutputFormat("XML","windows-1250",true);//Codepage Windows-1250 - Character Code Listing for Central Europe languages.
    of.setIndent(1);
    of.setIndenting(true);//JDOM API:This will set the indent String to use; this is usually a String of empty spaces.
    XMLSerializer serializer = new XMLSerializer(fos,of);
    ContentHandler hd = serializer.asContentHandler();//The Serializer interface is implemented by a serializer to enable users to: get an org.xml.sax.ContentHandler or a DOMSerializer to provide input to. 
    hd.startDocument();
    AttributesImpl atts = new AttributesImpl();//Construct a new, empty AttributesImpl object.
    hd.startElement("","","CONTACTS",atts);//To create root tag <Contacts>
    String line = null,tag;
    while ((line=in.readLine())!=null) {
        if(line.equals("Contact")){
            line=in.readLine();
            hd.startElement("","","CONTACT",atts);
            int i=0;
            while(!line.equals("Contact")){
                if(i==0)
                    tag="FirstName";
                else if(i==1)
                    tag="LastName";
                else{
                    if(p.matcher(line).matches())
                        tag="EMail";
                    else
                        tag="URL";
                }
                hd.startElement("","",tag,atts);
                hd.characters(line.toCharArray(),0,line.length());
                hd.endElement("","",tag);
                i++;
                line=in.readLine();
            }
            hd.endElement("","","CONTACT");
        }
    }
    hd.endElement("","","CONTACTS");
    hd.endDocument();
    fos.close();
    System.out.println("Work is done and check your file specified in the directory");
    in.close();
    }catch(Exception E){
        System.out.println("Cannot Generate XML!!!");
            }

        }
  }

Am I doing something wrong or is there any better way of doing this?

  • 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-05-24T08:52:35+00:00Added an answer on May 24, 2026 at 8:52 am

    This seems simple, as you load your contacts compare the contact you are loading to what you have already loaded. If it is a duplicate, you don’t really need to merge you just need to delete (or just stop loading) the duplicate contact.

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

Sidebar

Related Questions

$('tr').find(need help here).parent().css('backgroundColor', '#fcc'); Would like to perform inequality check of two dates (both
need help in error in database pivot. i have table tamed table_score like below:
I need help finishing this statement. It is frustrating that two of the PHP
I'm not sure what to tag this with, but I need help combining two
Can anyone help me perform the following... example: A B C D row 1
I'm trying to perform some realtime phone-number validation using javascript. I don't need help
can somebody help me to write a sql select to perform a task. So
I need help extending a functional update query that performs calculations on one record
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
Need help writing a script downloads data from google insight using c# this is

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.