Methods Summary |
---|
protected java.io.File[] | collectFiles(java.lang.String dir, java.lang.String pattern, boolean recursive, java.lang.Character digitWildcard)
FileWalker fileWalker ;
List list ;
fileWalker = new FileWalker( this ) ;
if ( digitWildcard != null )
fileWalker.setDigitWildcardChar( digitWildcard.charValue() ) ;
fileWalker.walkThrough( dir, pattern, recursive ) ;
list = this.getCollectedFiles() ;
return (File[])list.toArray( new File[list.size()]) ;
|
public boolean | directoryEnd(java.io.File dir)This method is called for each directory, that a FileWalker finished to walk through.
It must return true, if the FileWalker should continue. To stop the
calling FileWalker it can return false.
return true ;
|
public boolean | directoryStart(java.io.File dir, int count)This method is called for each directory, that a FileWalker starts to walk through.
It must return true, if the FileWalker should continue. To stop the
calling FileWalker it can return false.
return true ;
|
private static boolean | fileExists(java.io.File file)
boolean success = false ;
if ( file != null )
{
try
{
FileLocator locator = FileLocator.create( file ) ;
success = locator.exists() ;
}
catch ( Exception ex )
{
// nothing to do here
}
}
return success ;
|
public static java.io.File | findFile(java.lang.String filename)Tries to find the file with the given Name.
First it looks if the file exists directly under the given name.
If not, it searches the classpath to find it.
If the file was found and really exists, then it will be returned.
In all other cases null will be returned.
File aFile = null ;
aFile = new File( filename ) ;
if ( fileExists( aFile ) )
return aFile ;
aFile = findFileOnClasspath( filename ) ;
return aFile ;
|
public static java.io.File | findFileOnClasspath(java.lang.String filename)Tries to find the file with the given Name on the classpath.
If the file was found and really exists, then it will be returned.
In all other cases null will be returned.
ClassLoader cl = null ;
File file = null ;
URL url = null ;
try
{
cl = FileFinder.class.getClassLoader() ;
if ( cl == null )
{
// System.out.println( "No classloader found !\n<P>" ) ;
return null ;
}
url = cl.getResource( filename ) ;
if ( url == null )
{
// System.out.println( "Settings file '" + filename + "' not found in CLASSPATH !!!" ) ;
}
else
{
file = new File( url.getFile() ) ;
// System.out.println( "Settings file '" + file.getAbsolutePath() + "' exists: " + file.exists() ) ;
if ( ! fileExists( file ) )
file = null ;
}
}
catch ( Exception ex )
{
// ex.printStackTrace() ;
}
return file ;
|
public static java.io.File[] | findFiles(java.lang.String dir, java.lang.String pattern)Return all files that match the given pattern(s) start searching in the
specified dir. Searches in all sub directories as well.
More than one pattern can be specified in parameter pattern.
They have to be separated by ';'.
return findFiles( dir, pattern, true ) ;
|
public static java.io.File[] | findFiles(java.lang.String dir, java.lang.String pattern, boolean recursive)Return all files that match the given pattern(s) start searching in the
specified dir. Look into sub directories if recursive is true.
More than one pattern can be specified in parameter pattern.
They have to be separated by ';'.
return findFiles( dir, pattern, recursive, (char)0 ) ;
|
public static java.io.File[] | findFiles(java.lang.String dir, java.lang.String pattern, boolean recursive, char digitWildcard)Return all files that match the given pattern(s) start searching in the
specified dir. Look into sub directories if recursive is true.
Use the given digit wildcard in patterns to match single digits in
filenames.
More than one pattern can be specified in parameter pattern.
They have to be separated by ';'.
FileFinder finder ;
Character digitChar = null ;
if ( dir == null )
throw new IllegalArgumentException( "FileFinder.findFiles(): dir is null" ) ;
if ( pattern == null )
throw new IllegalArgumentException( "FileFinder.findFiles(): pattern is null" ) ;
if ( digitWildcard > 0 )
digitChar = new Character(digitWildcard) ;
finder = new FileFinder() ;
return finder.collectFiles( dir, pattern, recursive, digitChar ) ;
|
protected java.util.List | getCollectedFiles()
return collectedFiles ;
|
public boolean | handleException(java.lang.Exception ex, java.io.File file)This method is called for whenever an exception occurs in walking through
the directories.
The method must return true, if the FileWalker should continue. To stop the
calling FileWalker it can return false.
// System.out.println( "Problem with '" + file + "'" ) ;
// System.out.println( ex ) ;
return false ;
|
public boolean | handleFile(java.io.File file)This method is called for each file, that a FileWalker instance finds.
It must return true, if the FileWalker should continue. To stop the
calling FileWalker it can return false.
this.getCollectedFiles().add( file ) ;
return true ;
|
protected void | setCollectedFiles(java.util.List newValue) collectedFiles = newValue ;
|