www.pudn.com > charsettools_1.0.2.zip > ExtensionFileFilter.java
/*Program ExtensionFileFilter.java *
Author Keiven Ju *
Created 2003-12-19 6:14:03 *
Copyright 1995-1998,2000-2003 by AKuP International, Inc.,
*
Nanjing:
* Unit C, 26F Jianjiang Culture Building, No. 89 Zhongshannan Rd. Nanjing 210005 China
*
26F, Jianjiang Building No.89,Zhongshan South Rd, Nanjing *
Taipei :
*
5F, NO.6, Alley 36, Lane 26, Rueiguang Rd, Neihu District, Taipei City 114, Taiwan *
* All rights reserved.
*
* This software is the confidential and proprietary information
* of AKuP International, Inc. ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with AKuP.
*
* E-mail keiven.ju@akup.com for more information. */ package com.akup.charset.ui; import java.io.File; /** * program ExtensionFileFilter * @author Keiven Ju * @since 1.0.0 * @version 1.0.0 2003-12-19 6:14:03 */ public class ExtensionFileFilter extends javax.swing.filechooser.FileFilter { /** A description for the file type; */ private String description; /** The extension (for example, "png" for *.png files); */ private String extension; /** * Standard constructor. * @param description A description of the file type; * @param extension The file extension; */ public ExtensionFileFilter(String description, String extension) { this.description = description; this.extension = extension; } /** * Returns true if the file ends with the specified extension. * @param file The file to test; * @return A boolean that indicates whether or not the file is accepted by the filter; */ public boolean accept(File file) { if (file.isDirectory()) return true; String name = file.getName().toLowerCase(); if (name.endsWith(extension)) return true; else return false; } /** * Returns the description of the filter. * @return A description of the filter; */ public String getDescription() { return description; } }