hi i have two flat file having content like this
file1.txt

raghu,23,1000
ragiv,66,1800

file2.txt

ramya,45,2455
ragiv,66,1800

i need to compare the two file and print the content in the other file which are different among the two file i.e
raghu,23,1000
ramya,45,2455

plz help thanx in advance

i have put the contents into two arrays nw i m comparing the two array problem is when i m comparing i m able to print the equal content but not the unequal content.
i have to print the unequal part

here is the code:--

import java.io.*;
import java.util.*;
import java.lang.*;
public class reading
	{
public static void main(String args[]) throws Exception
	{
	try
	{
	//PUTTING THE CONTENTS IN TWO ARRAY
	 BufferedReader  br = new BufferedReader(new FileReader("item1.txt"));
       	String[] str = new String[50];
                  String thisLine = br.readLine();
        	int i = 0;
	              while (thisLine != null)
      		{           
               		str[i] = thisLine;
              		thisLine = br.readLine();
            		i++;
	   	}
	 BufferedReader  br1 = new BufferedReader(new FileReader("item2.txt"));
       	String[] str1 = new String[50];
                  String thisLine1 = br1.readLine();
        	int i1 = 0;
	              while (thisLine1 != null)
      		  {           
               		str1[i1] = thisLine1;
              		thisLine1 = br1.readLine();
            		i1++;
	        	}
		

	for(int n=0;n<4 ;n++)
		{
		for(int m=0;m<3;m++)
		{
			if (str[n].compareTo(str1[m])==0)
			{
			System.out.println("EQUAL====="+str[n]);
			}
			else
			{
		 	System.out.println("NOT EQUAL"+str[n]);
			System.out.println("NOT EQUAL"+str[m]);
			}
		}
		}
	br.close();
	br1.close();          
    	}  
catch(Exception e)
{
System.out.println("exception");
e.printStackTrace();
}
}
}

plz help

Use code tags and repost your code. I am not going to stress my eyes on that right now.

For help on code-tags read this and this.

Also looking at your code you need to follow some standard naming conventions, This is a link to code conventions as specified by Sun for Java.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.