Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.cantaa.util.filefilter;
 
 import java.io.File;
FileFilter for checking on File-Extension
 
 public class FileExtensionFilter implements FileFilter
{
   
Contains the File-Extension
   private String extension;

   
Constructor

Parameters:
extension The Extension to filter on (Example: ".txt" => include the dot)
   public FileExtensionFilter(String extension) {
      this. = extension;
   }

   

Returns:
true if the file has the specified extension, i.e. if the file name ends with that extension
   public boolean accept(File file) {
      // Only Files are checked
      if (!file.isFile()) {
         return false;
      }
      if ( == null) {
         return true;
      }
      return file.getName().endsWith();
   }
   public String getExtension() {
      return ;
   }
   public void setExtension(String extension) {
      this. = extension;
   }
New to GrepCode? Check out our FAQ X