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
- lineFRST = in1.readLine();
- lineSEC = in1.readLine();
- while((lineFRST != null) && (lineSEC != null)) {
- ...
- String[] thelineFRST = lineFRST.split(" ");
- String fileNo1 = thelineFRST[0];
- String[] thelineSEC = lineSEC.split(" ");
- String fileNo2 = thelineSEC[0];
- if(fileNo1.equals(fileNo2)) {
- printWriter.println(lineFRST);
- }
- else {
- printWriter.println(lineFRST);
- printWriter.println(lineSEC);
- }
1 : 30 at 2
2 : 35 at 2
4 : 30 at 2
Kindly please teach me...Thank you ....