

If a file contains a particular line more than one time, for the 1st time it is added to the set object and thus appended to the file writer. If the addition is successful, append that particular line to file writer.įinally, flush the contents of the FileWriter to the output file. Try to add this String to the Set object. Read each line of the file Store it in a Sting say input. Instantiate the FileWriter class (any class that writes data into a file) Instantiate Scanner class (any class that reads data from a file) Therefore, to remove duplicate lines from a File − The add() method of this interface accepts elements and adds to the Set object, if the addition is successful it returns true, if you try to add an existing element using this method, the addition operations fails returning false. Thanks for any suggestions.The interface set does not allow duplicate elements. Sure, could manually enter a return after each line, everytime new data is added to the list & resorted, but seems like a pain & should be a way to avoid it. Tried copying the sorted list from notepad++ (now w/o any blank lines) into a word processor, & format in double spacing, but the double space formatting isn't preserved when import the list into prgm using the list (uTorrent) - which requires the blank line between each text line. I need the "Sort outputs only UNIQUE" feature to remove duplicate lines more than alpha numeric sorting, but either way, still removes blank lines. So far, haven't figured out how to add blank lines BACK IN between each line of text or prevent blank lines from being removed during sorting, using notepad++, Excell / Open Office Calc or other. I can sort it OK in notepad++ or a spreadsheet, but they always remove the blank lines. The data needs to be used w/ a blank line between each line containing data. Trying to sort a column of plain text values w/o removing the carriage return (blank line) between each line of text.
