import java.io.*;
import javax.imageio.*;

/**
 * A file filter that only accepts images.
 */
class ImageFileFilter implements FileFilter {


  /** {@inheritDoc} */
  public boolean accept(File pathname) {
    String suffixes[] = ImageIO.getReaderFileSuffixes();
    String suffix = getSuffix(pathname);
    for (int i=0;i<suffixes.length;i++) {
      if (suffix.equals(suffixes[i].toUpperCase())) {
        return true;
      }
    }
    return false;
  }
  
  private String getSuffix(File f) {
    String tmp[] = f.getName().split("\\.");
    return tmp[tmp.length-1].toUpperCase();
  }
}
