搜索一个文件中好字的个数
public class FileReaderDemo {
//需求:搜索一个文件中好字的个数
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("e:\\templatefile\\file.txt");//这个流底层使用的是fileinputstream
int ch = 0;
int count = 0;
while((ch = fr.read())!= -1){
if(ch == '你'){
count++;
}
}
System.out.println("count="+count);
fr.close();
}
}