home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-09-28 | 867 b | 26 lines | [TEXT/CWIE] |
- import java.io.File;
- import java.io.FilenameFilter;
-
- public class ImageNameFilter implements FilenameFilter
- {
- /**
- * Tests if a specified file should be included in a file list.
- *
- * @param dir the directory in which the file was found.
- * @param name the name of the file.
- * @return <code>true</code> if the name should be included in the file
- * list; <code>false</code> otherwise.
- * @since JDK1.0
- */
- public boolean accept(File dir, String name)
- {
- //Need to filter for image files (files whose names end with
- //".jpg", ".gif", or ".jpeg", regardless of case).
- //Insert "ImageNameFilter accept"
- String upperCaseName = name.toUpperCase();
- return (upperCaseName.endsWith(".JPG") ||
- upperCaseName.endsWith(".JPEG") ||
- upperCaseName.endsWith(".GIF"));
- }
- }
-