code: public static List<File> listFiles(File srcPath) throws IOException
     {
        List<File> result = new ArrayList<File>();
  
        if (!srcPath.isDirectory())
        {
           throw new IOException(srcPath.getAbsolutePath() + " is a directory");
        }
  
        for (File subFile : srcPath.listFiles())
        {
           result.add(subFile);
           if (subFile.isDirectory())
           {
              result.addAll(listFiles(subFile));
           }
        }
  
        return result;
     }
docs: Returns the files list of whole directory including its sub directories.
  
  @param srcPath
  source path
  @return List
  @throws IOException
  if any exception occurred