Results 1 to 4 of 4
  1. #1
    Holic is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default About how to just print last 20 words from a input file

    I am a beginner for java. Now i have a question anyone would tell me how to write a code about how to print last 20 words from a input file? I was thinking about this like whole afternoon , but still cannot figure it out. SO i holp someone can help me. thx.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,306
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Holic View Post
    I am a beginner for java. Now i have a question anyone would tell me how to write a code about how to print last 20 words from a input file? I was thinking about this like whole afternoon , but still cannot figure it out. SO i holp someone can help me. thx.
    You need a queue that can store twenty slots, i.e. it you want to push in the 21st word, the 1st one falls out of the queue. At the end the queue contains the last 20 words.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Holic is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    can you tell me more specific. i still dont get it. thx a lot.

  4. #4
    Adomini is offline Member
    Join Date
    Aug 2010
    Posts
    70
    Rep Power
    0

    Default

    I believe what my good friend Jos is saying is that you need some way to store the words.

    I have heard people could possibly use arrays (not sure if you have learned that yet).

    But Jos is right - you need a way to store the words - then use that storage to output the words it contains.

    I hope that helps some. Any moderators here can correct me if I am wrong, since I am a partial newbie as well.

Similar Threads

  1. how to remove word words from txt file?
    By amroosobhy in forum New To Java
    Replies: 3
    Last Post: 10-08-2010, 01:49 PM
  2. Finding words (and more) in another file
    By Lund01 in forum Java Applets
    Replies: 5
    Last Post: 09-30-2010, 01:03 PM
  3. How to print words in different colours?
    By veen in forum New To Java
    Replies: 7
    Last Post: 06-10-2010, 04:54 PM
  4. Read in words from a text file that contains a story
    By Pleenen in forum Advanced Java
    Replies: 2
    Last Post: 05-27-2010, 04:34 AM
  5. Print the text file and print preview them
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-22-2008, 11:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •