Matcher match = Pattern.compile("[a-z]").matcher(str);
while (match.find())
lCount++;
match = Pattern.compile("[A-Z]").matcher(str);
while (match.find())
uCount++;
match = Pattern.compile("\\d").matcher(str);
while (match.find())
nCount++;
------解决方案--------------------
Java code
String fileName = "D:" + File.separator + "hello.txt";
File file = new File(fileName);
Reader reader = new InputStreamReader(new FileInputStream(file));
int temp = 0;
String s = "";
while ((temp = reader.read()) != -1) {
s += (char)temp;
}
reader.close();
System.out.println(s.length());//char长度
System.out.println(s);
------解决方案-------------------- java中一个char是两个字节