word counting app

Hey, im quite new to the whole java programming. I have been asked by a friend of mine to help produce a program which will read in a text file and display some of its attributes:
- number of words
- number of vouls
- frequency and lenght of words etc.

Would anyone have any code, or know of anywhere i might be able to find some code which could help with this task. I really dont know where to start so any help would be appreciated.

Thanks

Matt

Comments

  • Hi Matt,

    I am also new to java programming. Even i need a solution to same type of problem, so if you got the answer, please let me know.

    Thanks
    ranesh










    : Hey, im quite new to the whole java programming. I have been asked by a friend of mine to help produce a program which will read in a text file and display some of its attributes:
    : - number of words
    : - number of vouls
    : - frequency and lenght of words etc.
    :
    : Would anyone have any code, or know of anywhere i might be able to find some code which could help with this task. I really dont know where to start so any help would be appreciated.
    :
    : Thanks
    :
    : Matt
    :
  • look here this one aint that tough. first of all for counting words u need to read the whole file line by line and then possible use a stringtokeniser to get all the number of tokens. keep a running sum for the numtokens.Once you got each token i.e. each word u can then use a hash map to assign the string(key) to a value. everytime u read a line u line u check from the hashmap whether the key is already there n if so increment the value. u can then display the key value pairs when u have finished reading the file.
  • java.util.StringTokenizer stk=new java.util.StringTokenizer(YourTEXTString,SubstringToFind);
    int n=stk.countTokens();
  • Thanks, I am fairly new to Java myself, and any tips are very welcome.
  • I am actually doing something similar for my college/University project using methods:

    I will get you started.
    //Don't forget variables
    0123456789101112131415
    Sentence = "My Name Is Joe Bidden";
    startPosition = 0;
    EndPosition = Sentence.indexOf(" ",startPosition);

    Word =

    //Do a while loop to read in all the words

    while (EndPosition > 0)
    {
    System.out.println( your word
    }

    Hope that helps you get started.
  • I just finished the Program fully working I will post the codes as soon as I submit it in college.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories