/i want to count the no of alphabets from a to z in a file. The file is
"2.txt" and its contents are as under:
prateek
rawal
manit
/
import java.io.*;
public class count
{
public static void main(String args[])
{
int i=0;
String s;
try
{
BufferedReader b2= new BufferedReader(new FileReader("2.txt"));
while((s=b2.readLine())!=null)
{
System.out.println(s);
for(int j=0;j<s.length();j++)
{
if(s.charAt(j)>=97 && s.charAt(j)<=122)
System.out.println(i+=s.length());
}
}
b2.close();
}
catch(IOException o)
{
o.printStackTrace();
}
System.out.println("The no of alphabets in the file are"+i);
}
}
/There is no compilation error but it gives wrong output....please tell me
what is the problem./
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---