code: public static List<File> listAllFiles( File directory, boolean includeDirectories ) {
  
  		if( ! directory.isDirectory())
  			throw new IllegalArgumentException( directory.getAbsolutePath() + " does not exist or is not a directory." );
  
  		List<File> result = new ArrayList<> ();
  		List<File> directoriesToInspect = new ArrayList<> ();
  		directoriesToInspect.add( directory );
  
  		while( ! directoriesToInspect.isEmpty()) {
  			File currentDirectory = directoriesToInspect.remove( 0 );
  			if( includeDirectories )
  				result.add( currentDirectory );
  
  			File[] subFiles = currentDirectory.listFiles();
  			if( subFiles == null )
  				continue;
  
  			for( File subFile : subFiles ) {
  				if( subFile.isHidden()
  						|| subFile.getName().startsWith( "." ))
  					continue;
  
  				if( subFile.isFile())
  					result.add( subFile );
  				else
  					directoriesToInspect.add( subFile );
  			}
  		}
  
  		Collections.sort( result, new FileNameComparator());
  		return result;
  	}
docs: Finds all the files (direct and indirect) from a directory.
  <p>
  This method skips hidden files and files whose name starts
  with a dot.
  </p>
  
  @param directory an existing directory
  @param includeDirectories true to include directories, false to exclude them from the result
  @return a non-null list of files, sorted alphabetically by file names