Here you can find the source of createFileFilter(final String filter)
public static FileFilter createFileFilter(final String filter)
//package com.java2s; /*/*from w w w . jav a2s . c om*/ * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc. * All rights reserved. This program is made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * Contributors: * General Robotix Inc. * National Institute of Advanced Industrial Science and Technology (AIST) */ import java.io.File; import javax.swing.filechooser.FileFilter; public class Main { public static FileFilter createFileFilter(final String filter) { return new FileFilter() { public boolean accept(File f) { String ext = ""; String path = f.getPath(); int idx = path.lastIndexOf('.'); if (idx > 0) { ext = path.substring(idx + 1).toLowerCase(); if (ext.equals(filter)) return true; } return f.isDirectory(); } public String getDescription() { return filter + " files (*." + filter + ")"; } }; } }