Created
May 18, 2012 09:58
-
-
Save johnkil/2724392 to your computer and use it in GitHub Desktop.
Class for filtering File objects based on specific extension.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mtgclient.util; | |
import java.io.File; | |
import java.io.FilenameFilter; | |
/** | |
* Class for filtering File objects based on specific extension. | |
* | |
* @author e.shishkin | |
* | |
*/ | |
public class FileExtFilter implements FilenameFilter { | |
private final String ext; | |
/** | |
* Default constructor. | |
* | |
* @param ext - file extension WITHOUT A DOT (ex. "txt") | |
*/ | |
public FileExtFilter(String ext) { | |
this.ext = "." + ext; | |
} | |
@Override | |
public boolean accept(File dir, String filename) { | |
return filename.endsWith(ext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment