Hello,
I would like to count the number of whitespaces(Tab,Return,Spaces) in a given file I have tried so many times but I don't know why it's not working here is my code.
while (fileScan.hasNext()) {
count++;
String str=fileScan.next();
char[] chars =str.toCharArray();
int i;
for (i=0; i<str.length(); i++)
{
//Uppercase Letters
if (Character.isUpperCase(chars))
caps++;
//Lowercase Letters
else if(Character.isLowerCase(chars[i]))
lows++;
//Other Characters
else if(!Character.isLetter(chars[i]))
OtherCharachters++;
//Whitespaces
else if((chars[i]==' ')||(chars[i]=='\n')||(chars[i]=='\t'))
numOfWhitespaceChars++;
}
}
Thanks all inadvance.