Program to count Lines,Words,Char in a given file

import java.io.*;
import javax.swing.JOptionPane;
import java.util.*;
class Count
{
public static void main(String[] args) throws IOException
{
String s;
int i=0,count=0,l=0;
s=JOptionPane.showInputDialog("enter a file name");
FileInputStream f=new FileInputStream(s);
DataInputStream d=new DataInputStream(f);
while(d.readLine()!=null)
{
i++;
StringTokenizer s1=new StringTokenizer(d.readLine());
while(s1.hasMoreTokens())
{
String b=s1.nextToken();
count++;
l=l+b.length();
}
}
JOptionPane.showMessageDialog(null,"words="+count+"\nlines="+i+"\n characters="+l,"Message",JOptionPane.INFORMATION_MESSAGE);
}
}

All Rights Reserved The Origin for Screamers | Design by SCREAMERS
Computers
Top Blogs