62,615
社区成员
发帖
与我相关
我的任务
分享
BufferedReader br = new BufferedReader(new FileReader("xxx"));
int count = 0, read = 0;
while ((read=br.read()) != -1) {
count++;
}
br.close();
System.out.printf("char count = %d\n", count);
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);
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++;