import java.io.FileInputStream;
public class Panduan {
public static void main(String[] args) {
Panduan panduan = new Panduan();
panduan.readFile("D://test.txt");
}
public void readFile(String fileName){
int upperChar = 0;
int lowerChar = 0;
int digit = 0;
int otherChar = 0;
try {
FileInputStream fis = new FileInputStream(fileName);
byte[] buff = new byte[1024];
while(fis.available()>0){
int len = fis.read(buff);
String s = new String(buff,0,len);
for(int i=0;i
if(Character.isUpperCase(c)){
upperChar++;
} else if(Character.isLowerCase(c)){
lowerChar++;
} else if(Character.isDigit(c)){
digit++;
} else {
otherChar++;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("大写字母:"+upperChar+" "+"小写字母"+lowerChar+" "+"数字:"+digit+" "+"其他字符:"+otherChar);
}
}