• Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparing lines in a text file.  RSS feed

 
Rodrigo Aguilera
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i am learning Java and i need to make a little program that gets a text file and search for duplicate lines in it. The lines in the text file look like this :
2004-12-19 00:00:00.000,105,19:57:26,INI,DISCANDO INTRANET
2004-12-19 00:00:00.000,105,19:57:26,INI,DISCANDO INTRANET

Maybe there is a method to make this work.

thanks in advance.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to display duplicates or eliminate them? I started out thinking eliminate, but it's hard to tell from your question.

If duplicates appear next to each other, something like this will copy a file and remove duplicate lines:

If duplicates could appear anywhere, look into the Collections APIs to find one that doesn't store duplicates or one you could ask if a line already exists. Here's my Collections Crib Sheet that may help.


Let us know what you choose!
[ December 20, 2004: Message edited by: Stan James ]
 
Rodrigo Aguilera
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tip. I would like to remove the duplicated lines. I will let you know when i finish it.

thanks.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!