|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objectwave.utility.FileFinder
Useful for doing directory listings or locating a specific file. When doing
directory listings via the getAllFilenames command, the default filter is
for a file that ends with ".java".
One of the most beneficial commands is the getUrl command. Often times we
need to find files for our applications, and Java supports 3 ways to look
for these files. Rather than write this same code over and over this
provides all 3 in single method.
getUrl(java.lang.Class, java.lang.String)
,
getAllFilenames()
Nested Class Summary | |
static class |
FileFinder.Test
|
Field Summary | |
static java.io.FilenameFilter |
dirFilter
|
static java.io.FilenameFilter |
JAVA_FILTER
|
java.lang.String |
patternString
Set a pattern string to limit the results to files matching that pattern. |
Constructor Summary | |
FileFinder()
Constructor for the FileFinder object |
|
FileFinder(java.io.File f)
Constructor for the FileFinder object |
Method Summary | |
java.lang.String[] |
getAllFilenames()
Starting at the initial file location, search for all filenames matching the pattern string. |
java.lang.String[] |
getAllFilenames(java.io.File initialDirectory)
Starting at the initialDirectory location, search for all filenames matching the pattern string. |
java.lang.String[] |
getAllFilenames(java.io.File initialDirectory,
boolean recurse)
Starting at the initialDirectory location, search for all filenames matching the pattern string. |
java.lang.String[] |
getAllFilenames(java.lang.String file)
Starting at the initialDirectory location, search for all filenames matching the pattern string. |
java.lang.String |
getPatternString()
Gets the PatternString attribute of the FileFinder object |
java.lang.String |
getRelativePath(java.io.File targetFile)
Find the relative path to the provided file, using the initialFile as the source location. |
java.lang.String |
getRelativePath(java.io.File sourceDir,
java.io.File targetFile)
Find the relative path between two files. |
java.net.URL |
getUrl(java.lang.Class sourceClass,
java.lang.String fileName)
Look for the fileName to be an abosolute reference to a file. |
java.io.FilenameFilter |
getUserFilter()
Gets the UserFilter attribute of the FileFinder object |
protected void |
initialize()
|
java.lang.String[] |
list()
Provide a list of files in the initialFile directory. |
static void |
main(java.lang.String[] argv)
The main program for the FileFinder class |
void |
setInitialFile(java.io.File f)
Sets the InitialFile attribute of the FileFinder object |
void |
setPatternString(java.lang.String str)
Sets the pattern that is to limit the result set. |
void |
setUserFilter(java.io.FilenameFilter filt)
Use the provided FilenameFilter when getting file names. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.io.FilenameFilter JAVA_FILTER
public static final java.io.FilenameFilter dirFilter
public java.lang.String patternString
Constructor Detail |
public FileFinder()
public FileFinder(java.io.File f)
f
- Method Detail |
public static void main(java.lang.String[] argv)
argv
- The command line argumentspublic void setInitialFile(java.io.File f)
f
- The new InitialFile valuepublic void setPatternString(java.lang.String str)
str
- The pattern or null - If null, change filter to be "*.java"public void setUserFilter(java.io.FilenameFilter filt)
filt
- A custom FilenameFilterpublic java.net.URL getUrl(java.lang.Class sourceClass, java.lang.String fileName) throws java.net.MalformedURLException
sourceClass
- fileName
-
java.net.MalformedURLException
public java.lang.String getRelativePath(java.io.File targetFile)
targetFile
-
public java.lang.String getRelativePath(java.io.File sourceDir, java.io.File targetFile)
sourceDir
- Starting at this filetargetFile
- navigate to this file
public java.lang.String[] getAllFilenames()
public java.lang.String[] getAllFilenames(java.io.File initialDirectory)
initialDirectory
- A file representing a directory
public java.lang.String[] getAllFilenames(java.io.File initialDirectory, boolean recurse)
initialDirectory
- The place to begin the file searchrecurse
- boolean indicating to to traverse subdirectories
public java.lang.String[] getAllFilenames(java.lang.String file)
file
-
public java.lang.String getPatternString()
public java.io.FilenameFilter getUserFilter()
public java.lang.String[] list()
protected void initialize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |