com.massimo.utils
Class FileFinder

java.lang.Object
  extended by com.massimo.utils.FileFinder

public class FileFinder
extends Object

Use known paths, such as the classpath and the environment's PATHs, to find files


Field Summary
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
FileFinder()
           
 
Method Summary
static boolean addJavaPath(String path)
          Add all directories in path to the Java file search paths
static boolean addNativePath(String path)
          Add all directories in path to the native file search paths
protected static boolean addPath(Collection<String> collection, String path)
           
static boolean addTextPath(String path)
          Add all directories in path to the text file search paths
static String dump()
          Debug aid
static String findFile(Collection<String> paths, String name)
           
static String findFile(String name)
          Search all known paths
static String findJavaFile(String name)
          Search the java class paths
static String findNativeFile(String name)
          Search the native library locations
static String findTextFile(String name)
          Search text or property file locations.
protected static void loadJavaPaths()
          Load java search paths.
protected static void loadNativePaths()
          Load native search paths.
protected static void loadTextPaths()
          Load text search paths.
static void resetPaths()
          Reset all paths to their default values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log
Constructor Detail

FileFinder

public FileFinder()
Method Detail

addJavaPath

public static boolean addJavaPath(String path)
Add all directories in path to the Java file search paths

Parameters:
path - Path to add
Returns:
boolean True if any path was successfully added.

addNativePath

public static boolean addNativePath(String path)
Add all directories in path to the native file search paths

Parameters:
path - Path to add
Returns:
boolean True if any path was successfully added.

addPath

protected static boolean addPath(Collection<String> collection,
                                 String path)
Parameters:
collection - The path, or paths, are added to this colection
path - Path, or list of paths, to add
Returns:
boolean True if any path was successfully added.

addTextPath

public static boolean addTextPath(String path)
Add all directories in path to the text file search paths

Parameters:
path - Path to add
Returns:
boolean True if any path was successfully added.

dump

public static String dump()
Debug aid

Returns:
The paths to be searched

findFile

public static String findFile(Collection<String> paths,
                              String name)
Parameters:
paths - A Collection of paths to search
name - File name to search for
Returns:
The full filename of the file, or null if not found.

findFile

public static String findFile(String name)
Search all known paths

Parameters:
name - File name to search for
Returns:
The full filename of the file, or null if not found.

findJavaFile

public static String findJavaFile(String name)
Search the java class paths

Parameters:
name - File name to search for
Returns:
The full filename of the file, or null if not found.

findNativeFile

public static String findNativeFile(String name)
Search the native library locations

Parameters:
name - File name to search for
Returns:
The full filename of the file, or null if not found.

findTextFile

public static String findTextFile(String name)
Search text or property file locations.

Parameters:
name - File name to search for
Returns:
The full filename of the file, or null if not found.

loadJavaPaths

protected static void loadJavaPaths()
Load java search paths. This includes: java.class.path directories, java.ext.dirs, user.dir


loadNativePaths

protected static void loadNativePaths()
Load native search paths. This includes: java.library.path, user.dir


loadTextPaths

protected static void loadTextPaths()
Load text search paths. This includes: user.home, user.dir


resetPaths

public static void resetPaths()
Reset all paths to their default values.