public static void main(String[] args) {
List<File> files = getFiles("J:\\test");
for(File f : files){
InputStreamReader reader = null;
try {
reader = new InputStreamReader(new FileInputStream(f),"UTF-8");
BufferedReader br = new BufferedReader(reader);
String str=null;
while((str=br.readLine())!=null) {
System.out.println(f.getName() + str);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static List getFiles(String path){
File root = new File(path);
List files = new ArrayList();
if(!root.isDirectory()){
files.add(root);
}else{
File[] subFiles = root.listFiles();
for(File f : subFiles){
files.addAll(getFiles(f.getAbsolutePath()));
}
}
return files;
}