File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
DuplicateLinesElimination Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .io .*;
2+ class DuplicateElimination
3+ {
4+ public static void main (String [] args ) throws Exception
5+ {
6+ System .out .println ("Removing Duplicate lines in file" );
7+ BufferedReader br1 = new BufferedReader (new FileReader ("input.txt" ));
8+ PrintWriter pw = new PrintWriter ("output.txt" );
9+ String line = br1 .readLine ();
10+ while (line != null )
11+ {
12+ boolean available = false ;
13+ BufferedReader br2 = new BufferedReader ( new FileReader ("output.txt" ) );
14+ String target = br2 .readLine ();
15+ while (target != null )
16+ {
17+ if (line .equals (target ) )
18+ {
19+ available = true ;
20+ break ;
21+ }
22+ target = br2 .readLine ();
23+ }
24+ if (available == false )
25+ {
26+ pw .println (line );
27+ pw .flush ();
28+ }
29+ line = br1 .readLine ();
30+ }
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ Hello World..!!
2+ Hello World..!!
3+ Hello World..!!
4+ What's up :)
5+ What's up :)
6+ What's up :)
You can’t perform that action at this time.
0 commit comments