/* * [OnlyMatch.java] * * Summary: FilenameFilter for just matching exe or dll file, no directories. * * Copyright: (c) 2012-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2012-01-09 initial version. */ package com.mindprod.which; import java.io.File; import java.io.FilenameFilter; /** * FilenameFilter for just matching exe or dll file, no directories. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2012-01-09 initial version. * @since 2012-01-09 */ final class OnlyMatch implements FilenameFilter { /** * name of exe file to look for */ private final String toMatch; /** * constructor * * @param toMatch unqualified name of exe file to search for, ending in .exe */ OnlyMatch( final String toMatch ) { this.toMatch = toMatch; } /** * Select only Files with an extension in our want list * * @param dir the directory in which the file was found. * @param name the name of the file * * @return true if and only if the name should be included in the file list; false otherwise. */ public boolean accept( File dir, String name ) { final File f = new File( dir, name ); return !f.isDirectory() && name.equalsIgnoreCase( toMatch ); } }