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 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> 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 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