DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: help

  1. #1
    supa Guest

    help


    How to count the number of occurances of all the words in a text file using
    java?

  2. #2
    Simon Sellick simon.sellick Guest

    Re: help


    "supa" <supa_alwayscool@mailcity.com> wrote:
    >
    >How to count the number of occurances of all the words in a text file using
    >java?

    You could try:

    Decide what characters delimit a word and use strtok() on an input stream
    connected to the file to retrieve each word in turn. For each word, determine
    whether it is already present in an indexed list of word counts: if so, increment
    the count, otherwise add it and set the count to 1. I'll leave you to find
    a suitable class for holding the indexed set of word counts - there is a
    class perfectly suited.

    Good luck.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links