AFAIK, the StringTokenizer does not in itself remove characters; it breaks up a string in tokens at given delimeters. If StringTokenizer is constructed like this:
StringTokenizer st=new StringTokenizer("the fish was eaten by the cat");
...the default delimeters are:
- space character
- the tab character
- newline character
- carriage-return character
- form-feed character
If you want to remove the 'the' from your string, then the above construction would work, since the sentence consists of space characters that delimits each word.
And one way to remove the 'the' from the string, is using a simple little loop to check if the word, a token, is equals to 'the' or not.
Like such:
Create a new output string
Construct the StringTokenizer with the string that is to be parsed ("the fish was eaten by the cat")
Check each word with a loop:
While there is more tokens
Create a new temporary string with the nextToken()
If the temporary string does not equals 'the'
Add temporary string to the output string
(else do nothing)
print out the outputstring
...That should result in: "fish was eaten by cat"
Hope this is of any help,
/Soo-Im