递归输出文件夹下的所有文件
public static void listFileName(File file){
File[] files = file.listFiles();
for(File f : files){
if(f.isDirectory()){
listFileName(f);
}
System.out.println(f.getName());
}
}
统计某个单词出现的次数
public static int wordCount(String filePath, String word) throws IOException{
int count = 0;
BufferedReader reader = new BufferedReader(new FileReader(filePath));
String line = "";
while((line = reader.readLine()) != null){
count += ((line.length() - line.replace(word, "").length()) % line.length()) / word.length();
}
reader.close();
return count;
}