Here you can find the source of fileEndsInValidExtension(File file, FileNameExtensionFilter filter)
public static boolean fileEndsInValidExtension(File file, FileNameExtensionFilter filter)
//package com.java2s; //License from project: Open Source License import java.io.File; import javax.swing.filechooser.FileNameExtensionFilter; public class Main { public static final String WILDCARD = "*"; public static final String FILE_NAME_WITH_EXTENSION_REGEX = "^.*\\..+$"; public static boolean fileEndsInValidExtension(File file, FileNameExtensionFilter filter) { for (String ext : filter.getExtensions()) { if (file.toString().endsWith("." + ext) || (ext.equals(WILDCARD) && file.toString().matches(FILE_NAME_WITH_EXTENSION_REGEX))) { return true; }/*from w w w .j av a 2s . co m*/ } return false; } }