public static void main(String[] args)
{
BufferedReader bfr = new BufferedReader(new FileReader("d:\1.txt"));
StringBuffer sbf = new StringBuffer();
String line;
int character = 0,digital = 0, blank = 0, other = 0;
while((line = bfr.readLine()) != null)
{
sbf.append(line+"\r\n");
}
String str = sbf.toString();
char[] arr = str.toCharArray();
for(char c : arr)
{
if((c >= 'a' && a <= 'z') || (c >= 'A' && c <= 'Z'))
{
character++;
}
else if(c >= '0' || c <= '9')
{
digital = 0;
}
else if(c == ' ')
{
blank++;
}
else
{
other++;
}
System.out.println("输入的符串为:"+str);
System.out.println("总共字符数目为"+str.length());
System.out.println("字母数目"+character);
System.out.println("数字数目"+digital);
System.out.println("空格数目"+blank);
System.out.println("其他字符数目"+other);
}
}