Here you can find the source of readFileFolder(String filePath)
public static void readFileFolder(String filePath)
//package com.java2s; import java.io.*; public class Main { public static void readFileFolder(String filePath) { File file = new File(filePath); if (file.exists()) { if (file.isDirectory()) { System.out.println(file.getName()); File[] files = file.listFiles(); if (files != null && files.length > 0) { for (File f : files) { System.out.println(f.getName()); readFileFolder(f.getAbsolutePath()); }//from w w w . j a va 2 s . c om } } else { printFileContent(file.getAbsolutePath()); } } } private static void printFileContent(String filePath) { File file = new File(filePath); BufferedReader reader = null; try { reader = new BufferedReader(new java.io.FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { e.printStackTrace(); } } } }