public static List<File> findAllFiles(final File dir, final String fileSearchPattern)
	{
		final List<File> foundFiles = new ArrayList<>();
		// Get all files
		final File[] children = dir.getAbsoluteFile().listFiles();
		if (children == null || children.length < 1)
		{
			return foundFiles;
		}
		for (final File element : children)
		{
			// if the entry is a directory
			if (element.isDirectory())
			{ // then
				// find recursively in the directory and put it in a List.
				final List<File> foundedFiles = findAllFiles(element, fileSearchPattern);
				// Put the founded files in the main List.
				foundFiles.addAll(foundedFiles);
			}
			else
			{
				// entry is a file
				final String filename = element.getName();
				if (filename.matches(fileSearchPattern))
				{
					foundFiles.add(element.getAbsoluteFile());
				}
			}
		}
		return foundFiles;
	}
public static List < File > findAllFiles ( final File dir , final String fileSearchPattern ) { final List < File > foundFiles = new ArrayList < > ( ) ; final File [ ] children = dir . getAbsoluteFile ( ) . listFiles ( ) ; if ( children == null || children . length < 1 ) { return foundFiles ; } for ( final File element : children ) { if ( element . isDirectory ( ) ) { final List < File > foundedFiles = findAllFiles ( element , fileSearchPattern ) ; foundFiles . addAll ( foundedFiles ) ; } else { final String filename = element . getName ( ) ; if ( filename . matches ( fileSearchPattern ) ) { foundFiles . add ( element . getAbsoluteFile ( ) ) ; } } } return foundFiles ; }
Finds all files that match the search pattern. The search is not recursively.

@param dir
The directory to search.
@param fileSearchPattern
The regex file search pattern.
@return A List with all files that matches the search pattern.