Here you can find the source of createFileFilter(final String filterName, final String... extensionPatterns)
Parameter | Description |
---|---|
extensionPattern | a parameter |
filterName | a parameter |
public static FileFilter createFileFilter(final String filterName, final String... extensionPatterns)
//package com.java2s; //License from project: Open Source License import java.io.File; import javax.swing.filechooser.FileFilter; public class Main { /**/*from w w w .j av a 2 s . co m*/ * Creates file filter for files with specified extensions and filter name. * * @param extensionPattern * @param filterName * @return */ public static FileFilter createFileFilter(final String filterName, final String... extensionPatterns) { return new FileFilter() { @Override public boolean accept(final File f) { if (f.isDirectory()) { return true; } final String path = f.getAbsolutePath(); for (final String extension : extensionPatterns) { if (path.toLowerCase().endsWith(extension.toLowerCase())) { return true; } } return false; } @Override public String getDescription() { return filterName; } }; } }