*** Edited example to show order is not a factor
I have a file with the content:
ABC-123 BLA bla</br>
ABC-123 lala lala</br>
ABC-234 AAA</br>
ABC-123 CCC</br>
ABC-567 ddd</br>
ABC-234 BBB</br></br>
I would like to remove the lines that have a preceding line that begins with the same string and end up with a file containing (or a String containing):
ABC-123 BLA bla
ABC-234 AAA
ABC-567 ddd
Currently my code just saves the contents of the file into a string:
if (new File('description.txt').length() > 0 ) {
description = new File('description.txt').text
}
I'd like to either update the file or save the first 'non unique' lines plus unique lines in the description string.