Java Directory Check checkDirectory(File directory, String pckgname, ArrayList> classes)

Here you can find the source of checkDirectory(File directory, String pckgname, ArrayList> classes)

Description

Private helper method

License

Apache License

Parameter

Parameter Description
directory The directory to start with
pckgname The package name to search for. Will be needed for getting the Class object.
classes if a file isn't loaded but still is in the directory

Exception

Parameter Description
ClassNotFoundException an exception

Declaration

private static void checkDirectory(File directory, String pckgname, ArrayList<Class<?>> classes)
        throws ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.util.ArrayList;

public class Main {
    /**//from www  . ja  v  a 2 s .com
     * Private helper method
     *
     * @param directory The directory to start with
     * @param pckgname The package name to search for. Will be needed for
     * getting the Class object.
     * @param classes if a file isn't loaded but still is in the directory
     * @throws ClassNotFoundException
     */
    private static void checkDirectory(File directory, String pckgname, ArrayList<Class<?>> classes)
            throws ClassNotFoundException {
        File tmpDirectory;

        if (directory.exists() && directory.isDirectory()) {
            final String[] files = directory.list();

            for (final String file : files) {
                if (file.endsWith(".class")) {
                    try {
                        classes.add(Class.forName(pckgname + '.' + file.substring(0, file.length() - 6)));
                    } catch (final NoClassDefFoundError e) {
                        // do nothing. this class hasn't been found by the
                        // loader, and we don't care.
                    }
                } else if ((tmpDirectory = new File(directory, file)).isDirectory()) {
                    checkDirectory(tmpDirectory, pckgname + "." + file, classes);
                }
            }
        }
    }
}

Related

  1. checkDirCopy(File srcDir, File destDir)
  2. checkDirectory(File dir)
  3. checkDirectory(File directory)
  4. checkDirectory(File directory)
  5. checkDirectory(File directory)
  6. checkDirectory(File file)
  7. checkDirectory(File target)
  8. checkDirectory(final File directory)
  9. checkDirectory(final String dir, final boolean create, final String errorDirName)