Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package ch.cern.mig.utils;
 
 import java.io.File;
Filename filter which can be used to filter by regular expressions.

It can work in two modes:

  • match mode (default): filename must match the regular expression
  • find mode: regular expression occurs in the filename

Author(s):
Massimo Paladin - massimo.paladin@gmail.com
Copyright (C) CERN 2012-2013
public class RegExpFilenameFilter implements FilenameFilter {
    private Pattern regexp = null;
    private boolean matches = true;

    
Create a FilenameFilter given a Pattern in match mode.

Parameters:
pattern the pattern to be used during filtering
    public RegExpFilenameFilter(Pattern pattern) {
        this(patterntrue);
    }

    
Create a FilenameFilter given a Pattern.

Parameters:
pattern the pattern to be used during filtering
matches true if match mode should be applied, false if find mode should be used
    public RegExpFilenameFilter(Pattern patternboolean matches) {
        this. = pattern;
        this. = matches;
    }
    public boolean accept(File arg0String arg1) {
        if () {
            return .matcher(arg1).matches();
        } else {
            return .matcher(arg1).find();
        }
    }
New to GrepCode? Check out our FAQ X