Here you can find the source of newFileFilter(final String desc, final String[] allowed_extensions)
private static javax.swing.filechooser.FileFilter newFileFilter(final String desc, final String[] allowed_extensions)
//package com.java2s; //License from project: Open Source License public class Main { private static javax.swing.filechooser.FileFilter newFileFilter(final String desc, final String[] allowed_extensions) { return new javax.swing.filechooser.FileFilter() { @Override/*w w w . j av a 2 s.c om*/ public boolean accept(java.io.File f) { if (f.isDirectory()) { return true; } int pos = f.getName().lastIndexOf('.'); if (pos == -1) { return false; } else { String extension = f.getName().substring(pos + 1); for (String allowed_extension : allowed_extensions) { if (extension.equalsIgnoreCase(allowed_extension)) { return true; } } return false; } } @Override public String getDescription() { return desc; } }; } }