Skip to content

Instantly share code, notes, and snippets.

@johnkil
Created May 18, 2012 09:58
Show Gist options
  • Save johnkil/2724392 to your computer and use it in GitHub Desktop.
Save johnkil/2724392 to your computer and use it in GitHub Desktop.
Class for filtering File objects based on specific extension.
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