001package edu.pdx.cs410J.reflect;
002
003import java.io.*;
004
005/**
006 * This class provides an example of anonymous inner classes.  It uses
007 * inner classes to provide implementations of the {@link FileFilter}
008 * and {@link FilenameFilter} interfaces that find all files whose
009 * name ends with <code>.class</code>.
010 *
011 * @see edu.pdx.cs410J.core.FindJavaFiles
012 *
013 * @author David Whitlock
014 * @version $Revision: 1.2 $
015 *
016 * @since Spring 2003
017 */
018public class FindClassFiles {
019  private static void findFiles(File dir) {
020    final String suffix = ".class";
021
022    File[] classFiles = 
023      dir.listFiles(new FilenameFilter() {
024        public boolean accept(File dir, String name) {
025          return name.endsWith(suffix);
026        }
027      });
028
029    for (int i = 0; i < classFiles.length; i++)
030      System.out.println(classFiles[i]);
031
032    File[] subdirs = 
033      dir.listFiles(new FileFilter() {
034        public boolean accept(File file) {
035          return file.isDirectory();
036        }
037      });
038
039    for (int i = 0; i < subdirs.length; i++)
040      findFiles(subdirs[i]);
041  }
042}