473,498 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

comparing two output lines.

281 Contributor
I need help on comparing lines in my output file...
How to delete the second line in text file (FileReader) and print out the first line for the same fileno?

I put here sample of my output file:

1 : 30 at 2
1 : 134 at 10
2 : 35 at 2
4 : 30 at 2
4 : 80 at 8
..........
...........

The problem here is, not all file numbers ([0]) have same file numbers.
What I can think is something like this..but I still got the repeated fileno in my new output file.

Expand|Select|Wrap|Line Numbers
  1. lineFRST = in1.readLine(); 
  2. lineSEC = in1.readLine();      
  3.  
  4. while((lineFRST != null) && (lineSEC != null))   {    
  5. ...
  6. String[] thelineFRST = lineFRST.split(" ");
  7. String fileNo1 = thelineFRST[0];
  8.  
  9. String[] thelineSEC = lineSEC.split(" ");
  10. String fileNo2 = thelineSEC[0];
  11.  
  12. if(fileNo1.equals(fileNo2)) {
  13.                printWriter.println(lineFRST); 
  14.             }
  15.             else     {  
  16.                 printWriter.println(lineFRST); 
  17.                 printWriter.println(lineSEC); 
  18.             } 
  19.  
My new output should look like this:
1 : 30 at 2
2 : 35 at 2
4 : 30 at 2


Kindly please teach me...Thank you ....
May 15 '07 #1
0 1070

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2954
by: Doug | last post by:
I need to compare two "address" structures within a document, and perform some action if they are not equal. The XML document is a purchase order, with an address at both the header and line...
3
2006
by: Robert Dell | last post by:
I have a problem comparing strings in an order form i'm writing. I want to give a running total at the bottom of the page and it appears to be working except it doesn't compare correctly (it...
7
1698
by: Chéraaar | last post by:
Hi, I have the following problem: In one file (addresses) I have a bunch of lines like this: New 0x8048240 Old 0x0: jne 804824a New 0x8048253 Old 0x0: je 8048293 New 0x80482c7 Old 0x0: jp...
6
3589
by: Holger Kasten | last post by:
Hello, I am looking for a fast and efficient way to compare two text files and create a thrid one. E.g. Input file 1: Number 1 Number 2
8
7503
by: Frost | last post by:
Hi All, I am a newbie i have written a c program on unix for line by line comparison for two files now could some one help on how i could do word by word comparison in case both lines have the...
3
4251
by: s99999999s2003 | last post by:
hi i wrote some code to compare 2 files. One is the base file, the other file i got from somewhere. I need to compare this file against the base, eg base file abc def ghi eg another file
2
2730
by: TamaThps | last post by:
I have to write a program that takes the lines of code from a .cpp as a string into an array. Then I need to compute the ratio of total lines of code to the number of comment lines, and ratio of...
1
4996
by: xtremebass | last post by:
Hi Bytes.. In Linux, How can i get return value of comparing two files using the command cmp in the prompt.. when i was tried, it shows only output of unmatched lines(differ line )/ shows nothing...
1
2309
by: Avi1 | last post by:
Hi, I got the code (from the internet)for comparing two files and showing the difference in contents.Now,I tried the same code for two files written in japanese language(kanji).If I save the two...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.