hi all, need a little help i am to write a program to read a file , then scrubber it then count double and sort and print(not really in this order). i am "trying" to write this it part by part, but i am running into some problems.

this is what i have to do or how it should look.

Put the File in the Scanner object and read it a token at a time using the next( ) method. This will need to be inside of a while-loop which tests to see if the File has another token to read.

Next, you want to take the individual tokens and pass them to a scrubber method that receives the token as a parameter and returns a String containing the original token, but with any punctuation removed and the entire String in small letters.

Your code should be formatted like the following meta-code:

while( "the Scanner has more tokens" ) {

String nextToken = "get next token from Scanner"

String nextWord = "retrun value from scrubber method when passed nextToken"

"Add nextWord to the ArrayList

}


After all words have been found, sort the ArrayList using the Collections class


create an output-loop to write to the new File, as long as the size to the ArrayList is greater than zero.



Inside of the loop, create an String for output and set it equal to the first element of the ArrayList. Then you will need to concatenate the word count to the output String before you write it out to the File. The process of the output loop will look like this in meta-code.

while ( "ArrayList has more elements" ) {

String nextWord = "get first element off of the ArrayList"

int counter = 1

"delete the first element of the ArrayList (the one just read)"



while( " the new 1st element of the ArrayList is equal to 'nextWord' " ) {

" delete the first element off of the ArrayList and INCREMENT the counter "
}



" concatenate the counter value to nextWord, adding a single space, a star, and finally the counter value "

" output nextWord to the File using <"the name of your PrintStream object">.println(nextWord)[/I]



this is how my code looks right now.


Java Code:
import java.util.Scanner;
import java.io.*;


public class ExercisesE {

    public static void main(String[] Args) throws FileNotFoundException {

     
      Scanner inputFile = new Scanner(new File("test.txt"))
          .useDelimiter(",");

      printDuplicates(inputFile);
    }

    public static void printDuplicates(Scanner Input){

        int lastWordCount = 0;
        String lastWord = null;

        while(Input.hasNext()){

            
            String nextWord = Input.next();

           
            if(!nextWord.equals(lastWord)) {
                if(lastWordCount > 1) {
                    System.out.println(lastWord + "*" + lastWordCount);
                }
                lastWordCount = 0;
            }

            lastWord = nextWord;
            lastWordCount++;
        }

        
        if(lastWordCount > 1) {
            System.out.println(lastWord + "*" + lastWordCount);
        }
    }
}

it compile no error but nothing prints out. what am i missing. appreciate the help.