Remove Duplicate Lines from Text using Java
I was wondering if anyone has logic in java that removes duplicate lines while maintaining the lines order. I would prefer no regex solution. Emil public class UniqueLineReader extends BufferedReader { Set<String> lines = new HashSet<String>(); public UniqueLineReader(Reader arg0) { super(arg0); } @Override public String readLine() throws IOException { String uniqueLine; if (lines.add(uniqueLine = super.readLine())) return uniqueLine; return ""; } //for testing.. public static void main(String args[]) { try { // Open the file that is the first // command line parameter FileInputStream fstream