The Java code below is to be reviewed, make suggestions for corrections and improvement.

others

Description

The Java code below is to be reviewed, make suggestions for corrections and improvement. 

With that, the code is a class that will inspect an ASCII text file and return statics about the file.  I am having problems with my Javac.exe and need help really fast.

The below code is to tested:

/*
    Program for counting no. of Chars, Words and Lines in a text file.
*/

import java.lang.*;
import java.io.*;
import java.util.*;
class WordCount
{
  public static void main(String arg[]) throws Exception
    {
        int char_count=0;
            int word_count=0;
            int line_count=0;
            String s;
            StringTokenizer st;
            BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
            System.out.print("Enter filename : ");
            s=buf.readLine();
            buf=new BufferedReader(new FileReader(s));
            while((s=buf.readLine())!=null);
            {
                line_count++;
                st=new StringTokenizer(s," ,;:");
                while(st.hasMoreTokens())
                {
                    word_count++;
                    s=st.nextToken();
                    char_count+=s.length();
                }
            }
            System.out.println("Character Count : "+char_count);
            System.out.println("Word Count : "+word_count);
            System.out.println("Line Count : "+line_count);
            buf.close();
    }
}


Related Questions in others category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.