Removing Duplicates – Java

Hi Experts,

I have a question. I have an object and want to insert in a text file. Before inserting, I want to check if it is duplicate. If no duplicate is found, I will insert the object. If yes, will not insert an object? Do I need a collection for this? This is for Java. Thank you!