private static List<File> findFilesInDirectory(File directory,
			Pattern pattern, boolean scanRecursive) {
		List<File> files = new ArrayList<File>();
		String[] filesInDirectory = directory.list();
		if (filesInDirectory == null) {
			return files;
		}
		for (String fileToCheck : filesInDirectory) {
			File file = new File(directory, fileToCheck);
			if (file.isFile()) {
				if (pattern.matcher(fileToCheck).matches()) {
					files.add(file);
				}
			} else if (file.isDirectory()) {
				if (scanRecursive) {
					files.addAll(findFilesInDirectory(file, pattern,
							scanRecursive));
				}
			}
		}
		return files;
	}
private static List < File > findFilesInDirectory ( File directory , Pattern pattern , boolean scanRecursive ) { List < File > files = new ArrayList < File > ( ) ; String [ ] filesInDirectory = directory . list ( ) ; if ( filesInDirectory == null ) { return files ; } for ( String fileToCheck : filesInDirectory ) { File file = new File ( directory , fileToCheck ) ; if ( file . isFile ( ) ) { if ( pattern . matcher ( fileToCheck ) . matches ( ) ) { files . add ( file ) ; } } else if ( file . isDirectory ( ) ) { if ( scanRecursive ) { files . addAll ( findFilesInDirectory ( file , pattern , scanRecursive ) ) ; } } } return files ; }
This class is the recursive part of the file search.

@param directory
@param pattern
@param scanRecursive
@return