Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Removing duplicate words from a file

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    114
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Removing duplicate words from a file

    There is a file with data and i have to remove the duplicate words from a file and write the non repeated words to other file. Does anyone have tried the optimal solution for this?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Removing duplicate words from a file

    What about the straight forward, simple solution? Do you have that working? Then worry about making it optimal.

  3. #3
    Member
    Join Date
    Mar 2011
    Posts
    114
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Removing duplicate words from a file

    My idea is to read all the words in a file in to a LinkedHashSet. And once the file read we can write the contents of LinkedHashSet to a second file.

Similar Threads

  1. Removing Duplicate Values From an Array
    By nicsa in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 30th, 2011, 07:55 PM
  2. Issue with code. Does not detect duplicate names in file
    By suxen in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 29th, 2011, 01:13 AM
  3. How would you check for duplicate usernames in a file?
    By suxen in forum Java Theory & Questions
    Replies: 1
    Last Post: March 28th, 2011, 11:35 PM
  4. Counting Words in a File with a Loop
    By bengregg in forum Loops & Control Statements
    Replies: 17
    Last Post: February 11th, 2011, 10:11 AM
  5. [SOLVED] Enhancement in program of removing whitespace from text file
    By John in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: April 27th, 2009, 09:36 AM