Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #10966

comparing two test files

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!v24g2000prn.googlegroups.com!not-for-mail
From ruds <rudranee@gmail.com>
Newsgroups comp.lang.java.programmer
Subject comparing two test files
Date Fri, 23 Dec 2011 00:45:59 -0800 (PST)
Organization http://groups.google.com
Lines 43
Message-ID <5fdf65a2-052b-4c0b-b6bf-bc4dc8a7dd02@v24g2000prn.googlegroups.com> (permalink)
NNTP-Posting-Host 124.247.239.63
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1324630060 20410 127.0.0.1 (23 Dec 2011 08:47:40 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Fri, 23 Dec 2011 08:47:40 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info v24g2000prn.googlegroups.com; posting-host=124.247.239.63; posting-account=UzevbQoAAABu6FGaSl5tpeOJ7IcNa6Ko
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-Header-Order ARLEUHNKC
X-HTTP-UserAgent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322),gzip(gfe)
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10966

Show key headers only | View raw


Hi,
I want to compare the content of two files, which in turn gives me the
output which lines are deleted from latest version and which lines are
added in it and also if the first line no is same is details changed.
I am reading the first file line by line using BufferedReader and the
opening the second file that is the latest version in another while
loop and checking for match.
But after checking the first line, I am unable to read the second file
again and again.
Here  is the code:


FileReader fin1=new FileReader(args[0]);
FileReader fin2=new FileReader(args[1]);
BufferedReader br1=new BufferedReader(fin1);
BufferedReader br2=new BufferedReader(fin2);

while((line1 = br1.readLine())!= null)
{
 str1=tokens1[2].trim();
 while ((line2 = br2.readLine())!= null)
 {
  str2=tokens2[2].trim();
  if(str1.equals(str2))
  {
   for(j=0;j<tokens1.length;j++)
   {
     str3=tokens1[j].trim();
     if(!(line2.contains(str3))) { //output to file that record is
changed}
   }
 }
 else{ // str1 is not present in the file}
} //end of while for second file
} //end of while for firsts file

it iterates through the first file but doest not enter the second
while loop after reading once onle i.e for the first line of first
file.

Kindly help.

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar | Unroll thread


Thread

comparing two test files ruds <rudranee@gmail.com> - 2011-12-23 00:45 -0800
  Re: comparing two test files Jeff Higgins <jeff@invalid.invalid> - 2011-12-23 05:27 -0500
    Re: comparing two test files Jeff Higgins <jeff@invalid.invalid> - 2011-12-23 06:03 -0500
  Re: comparing two test files Patricia Shanahan <pats@acm.org> - 2011-12-23 06:37 -0800
    Re: comparing two test files Gene Wirchenko <genew@ocis.net> - 2011-12-23 09:18 -0800
      Re: comparing two test files Patricia Shanahan <pats@acm.org> - 2011-12-23 10:25 -0800
        Re: comparing two test files Gene Wirchenko <genew@ocis.net> - 2011-12-23 11:13 -0800
          Re: comparing two test files Patricia Shanahan <pats@acm.org> - 2011-12-23 11:45 -0800
  Re: comparing two test files markspace <-@.> - 2011-12-23 07:50 -0800

csiph-web