This code finds the number of occurrences of a word in a particular text string with the StringTokenizer class. Is case-sensitive.
/ / word: the word you wish to search in the text.
/ / TextoBusc: text which deesa look up the word. Void boolean uppercase = true;
numPalabras int = 0, / / \u200b\u200bCount the number and words in the text
String token = "";
/ / Using StringTokenizer Class StringTokenizer
Search = new StringTokenizer (TextoBusc, "\\ "'!., \\ t \\ n ()[]?-_@");
while (Busca.hasMoreTokens ()! = false) {String
Busca.nextToken palabrilla = ();
if (shift) / / uppercase and lowercase Differentiating between
if (palabrilla.equals (word)) numPalabras + +;
else / / No dereference between uppercase and lowercase
if (palabrilla. toLowerCase (). equals (palabra.toLowerCase ())) numPalabras + +;
}}
0 comments:
Post a Comment