// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.File;

import javax.swing.filechooser.FileFilter;

public class WawFilter extends FileFilter {
   public boolean accept(File f) {
      String name = f.getName().toUpperCase();
      if(f.isDirectory() ||
         (name.length() >= 4 && name.substring(name.length()-4).equals(".WAW"))) {
         return true;
      } else {
         return false;
      }
   }
   public String getDescription() {
      return "waw files";
   }
   public static void main(String[] arg) {
      FileFilter f = new WawFilter();
      System.out.println(f.accept(new File("z.waw")));
      System.out.println(f.accept(new File("z.dat")));
      System.out.println(f.accept(new File("\\")));
      System.out.println(f.accept(new File(".")));
      System.out.println(f.accept(new File("..")));
      System.out.println(f.accept(new File("z.z")));
   }
}
