I really need help with this code...I have to display statistics from each and use Scanner and Tokenizer. For displaying each character I have to use Character.isLetter(). Please help me figure out how to display all of these things from a file.
//TextFileStats.java
//Print out Statistics using StringTokenizer.
import java.io.*;
import java.util.*;
import java.lang.*;
public class TextFileStats
{
public static Scanner scanner;
public static int wordCount;
public static int paragraphCount;
public static int charPerWordCount;
public static int sentenceCount;
public static int lineCount;
public static int charCount;
public static void main( String args[] ) throws IOException, NumberFormatException, FileNotFoundException
{
scanner = new Scanner( new File( "C:\\README.txt" ) );
while( scanner.hasNext() )
{
String input = scanner.nextLine();
StringTokenizer tokenizer = new StringTokenizer( input );
lineCount++;
while ( tokenizer.hasMoreTokens() )
{
tokenizer.nextToken();
wordCount = 0;
wordCount++;
String character = tokenizer.nextToken();
boolean isCharacter = false;
int = 0;
while( i < tokenizer.length() && isCharacter )
{
String ch = tokenizer.substring( i, i + 1 );
if( ch.compareTo
charCount = Integer.parseInt( tokenizer.nextToken() );
charPerWordCount = Integer.parseInt( tokenizer.nextToken() );
sentenceCount = Integer.parseInt( tokenizer.nextToken() );
paragraphCount = Integer.parseInt( tokenizer.nextToken() );
}
}//end StringTokenizer
scanner.close();
//print out statistics
System.out.println( "Page count: " + lineCount/60 );
System.out.println( "Word count: " + wordCount );
System.out.println( "Character count: " + charCount);
System.out.println( "Character per word count: " + charPerWordCount );
System.out.println( "Sentence count: " + sentenceCount );
System.out.println( "Paragraph count: " + paragraphCount );
}
}