Results 1 to 3 of 3
  1. #1
    jaq
    jaq is offline Member
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Unhappy Counting specific word from a file

    hi...

    I have a text file containing " How are you? where are you? "

    Now i need to read this file and display how many "YOU" and "ARE" are there.I know to read and display the contents but not aware of counting the words?? can anybody please help.

    Thanks in advance.

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

    Default

    Quote Originally Posted by jaq View Post
    hi...

    I have a text file containing " How are you? where are you? "

    Now i need to read this file and display how many "YOU" and "ARE" are there.I know to read and display the contents but not aware of counting the words?? can anybody please help.

    Thanks in advance.
    Read the API documentation for the String class and pay special attention to the indexOf( ... ) methods. Also a Map<String, Integer> might come in handy.

    kind regards,

    Jos

  3. #3
    CodesAway's Avatar
    CodesAway is offline Senior Member
    Join Date
    Sep 2009
    Location
    Texas
    Posts
    238
    Rep Power
    5

    Default

    Quote Originally Posted by jaq View Post
    I know to read and display the contents but not aware of counting the words??
    Are you able to get each individual word?

    In order to count how many times a word occurs, you must first be able to get each word. Then, you count them. By breaking the problem down into parts, you can solve one part at a time, and they build to the solution.
    CodesAway - codesaway.info
    writing tools that make writing code a little easier

Similar Threads

  1. Replies: 2
    Last Post: 11-17-2009, 04:12 PM
  2. printin word file
    By pinks_70986 in forum New To Java
    Replies: 2
    Last Post: 07-12-2009, 03:26 PM
  3. Replies: 7
    Last Post: 11-19-2008, 02:09 PM
  4. Replies: 2
    Last Post: 11-08-2008, 10:40 AM
  5. [SOLVED] Help on Word and Character counting in java
    By Alistair in forum New To Java
    Replies: 2
    Last Post: 05-15-2008, 03:48 AM

Posting Permissions

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