📄 filenamesuffixfilter.java
字号:
/*====================================================================*\FilenameSuffixFilter.javaFilename suffix filter class.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program. If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// PACKAGEpackage util;//----------------------------------------------------------------------// IMPORTSimport java.io.File;//----------------------------------------------------------------------// FILENAME SUFFIX FILTER CLASSpublic class FilenameSuffixFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter{////////////////////////////////////////////////////////////////////////// Constructors//////////////////////////////////////////////////////////////////////// public FilenameSuffixFilter( String suffix, String description ) { this.suffixes = new String[1]; suffixes[0] = suffix.toLowerCase( ); this.description = description; } //------------------------------------------------------------------ public FilenameSuffixFilter( String[] suffixes, String description ) { this.suffixes = new String[suffixes.length]; for ( int i = 0; i < suffixes.length; ++i ) this.suffixes[i] = suffixes[i].toLowerCase( ); this.description = description; } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods : FileFilter interface//////////////////////////////////////////////////////////////////////// public boolean accept( File file ) { if ( file.isDirectory( ) ) return true; String filename = file.getName( ).toLowerCase( ); for ( String suffix : suffixes ) { if ( filename.endsWith( suffix ) ) return true; } return false; } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods//////////////////////////////////////////////////////////////////////// public String getSuffix( int index ) { return suffixes[index]; } //------------------------------------------------------------------ public String getDescription( ) { return description; } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance variables//////////////////////////////////////////////////////////////////////// private String[] suffixes; private String description;}//----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -