|
hi i am new to java and i got some problems here.
simply i just want to code a program to count the words, syllables and sentences in a doucment. But i dont know how to code that, hope someone will help me out.
|
|
|
use Stringtokenizer
Something like this
int lineCount=0;
String lineSeperator="";
String docString="Hello This is test for\n text example";
StringTokenizer toeknizer = new StringTokenizer(docString);
System.out.println("Words Found "+toeknizer.countTokens());
toeknizer = new StringTokenizer(docString,"\n");
lineCount=toeknizer.countTokens();
lineSeperator = System.getProperty("line.separator");
toeknizer = new StringTokenizer(docString,lineSeperator);
lineCount=lineCount+toeknizer.countTokens();
System.out.println("Lines Found "+lineCount);
|
|
|
|
|
|
|
// |