Advertisement

12.13.2007 at 04:22AM PST, ID: 23020826
[x]
Attachment Details

file comparison

Asked by motolanix1 in Java Programming Language

Tags: file, comparison, methods

Hi All,

I am trying to match the contents of two text files which are tab delimited. If i shift a tab to the left or right in a file or change a word or anything in one of the files, it should not match the other file. Now In the code below i need to merge the two while loops together and then i can do a check to see if the contents match, because the IF statement is not matching anything at the moment because there is nothing to match. I think a boolean method would better to check whether the contents of each file match?. Can you help me with this. Speedy reply would be very much appreciated.      

  try {
         
                BufferedReader in1 = new BufferedReader(new FileReader("C:\\file1.txt"));
                BufferedReader in2 = new BufferedReader(new FileReader("C:\\file2.txt"));
                
                String line1;
                String line2;
                
                   while ((line1 = in1.readLine()) != null) {
                   
                        System.out.println("Data in file 1 is:" +line1);
                      
                    }
                   
               while ((line2 = in2.readLine()) != null) {
                   
                        System.out.println("\nData in file 2 is:" +line2);
                     
                    }  
                          
                    if(line1 == line2){
                  
                   System.out.println("\nData in file match");      
                    }
                         
                         else{
                                  
                   System.out.println("\nData in file do not match");      
                         }
                                                  
                  }
                                       
                          catch (IOException e) {
            e.printStackTrace();
       
              }  Start Free Trial
[+][-]12.13.2007 at 04:44AM PST, ID: 20463904

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.13.2007 at 04:45AM PST, ID: 20463907

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.13.2007 at 04:45AM PST, ID: 20463908

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: file, comparison, methods
Sign Up Now!
Solution Provided By: dejanpazin
Participating Experts: 5
Solution Grade: A
 
 
[+][-]12.13.2007 at 05:01AM PST, ID: 20463961

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.13.2007 at 05:24AM PST, ID: 20464059

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.13.2007 at 03:18PM PST, ID: 20468583

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.13.2007 at 03:21PM PST, ID: 20468598

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628