Advertisement

12.12.2007 at 10:41AM PST, ID: 23019139
[x]
Attachment Details

Compare two txt files

Asked by motolanix1 in Java Programming Language

Tags: java, compare, files, two

Hi All,

I am abit rusty with my Java. Basically what im trying to do is compare the data in two text files. Basically they should match. The data in the files are separated by tabs i.e.somestring tab somestring tab etc. If they match, then program will display that they match. If they dont, then program will say that they dont match. My program is not quite correct. Can anyone help with my program as i need to get this running correctly urgently. I have had very good feedback from everyone so thanks. Speedy reply would be very much appreciated! Have a look at the my program below and edit where appropriate.

                   InputStream inputStream1, inputStream2 = null;

                         try
                         {
                               
                                              inputStream1 = new FileInputStream("C:\\file1.txt");
                             inputStream2 = new FileInputStream("C:\\file2.txt");
                             
                 boolean match (InputStream inputStream1, InputStream inputStream2){
                                                  
                 While (true){
                                                    
                   if (inputStream1 == inputStream2){
                                         
                       return true;
                       System.out.println("Files match");
                                         
                       }
                                   
                      else{
                                               
                      return false;
                       System.out.println("Files do not match");      
                       }
                 }
       }
}
                        
                        catch( FileNotFoundException e )
                        {
                        e.printStackTrace();
                        }Start Free Trial
[+][-]12.12.2007 at 10:45AM PST, ID: 20459077

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.12.2007 at 11:04AM PST, ID: 20459218

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.12.2007 at 02:21PM PST, ID: 20460712

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: java, compare, files, two
Sign Up Now!
Solution Provided By: objects
Participating Experts: 4
Solution Grade: B
 
 
[+][-]12.12.2007 at 09:30PM PST, ID: 20462590

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