|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.sandia.ccaffeine.dc.user_iface.applet.FileSearch
public class FileSearch
Search a folder hierarchy for filenames that end with the desired extensions. For example, if the desired filename extensions are {"txt", "text", "htm", "html"} then we will search for files whose names end with .txt, .text, .htm, or .html.
EXAMPLE:
FileSearch x = new FileSearch();
x.setFolderName("c:/myData");
x.setExtension(new String[] {"txt","text","htm","html"});
x.doStart();
String foundFilenames[] = x.getFoundFilenames();
Field Summary | |
---|---|
protected boolean |
debug
|
protected java.lang.String[] |
filenameExtensions
|
protected java.lang.String |
folderName
|
protected java.lang.String[] |
foundFilenames
|
Constructor Summary | |
---|---|
FileSearch()
Construct a new FileSearch object. |
Method Summary | |
---|---|
java.lang.Object |
clone()
|
void |
doStart()
Search the target folder for filenames that end with one of the target extensions. |
protected boolean |
filenameEndsWithOneOfTheseExtensions(java.lang.String filename,
java.lang.String[] extensions)
Return true if the filename ends with one of the extensions in the extensions[] array. |
java.lang.String |
getFilenameExtension(int index)
Search for files whose names end with one of these extensions. |
java.lang.String[] |
getFilenameExtensions()
Search for files whose names end with these extensions. |
java.lang.String |
getFolderName()
Retrieve the name of the folder that we are going to search. |
java.lang.String[] |
getFoundFilenames()
Retrieve an array that contains the names of all the files we are searching for. |
static void |
main(java.lang.String[] args)
|
protected java.lang.String[] |
searchFolderForFilenamesWithExtensions(java.lang.String folderName,
java.lang.String[] extensions)
Search the input folder (and all subfolders) for filenames with the correct extensions. |
protected java.util.Vector |
searchFolderForFilenamesWithExtensions(java.lang.String folderName,
java.lang.String[] extensions,
java.util.Vector namesOfFoundFiles)
Search the input folder (and all subfolders) for filenames with the correct extensions. |
void |
setFilenameExtensions(java.lang.String[] filenameExtensions)
Search for files whose names end with these extensions. |
void |
setFolderName(java.lang.String folderName)
Set the name of the folder we are going to search. |
void |
setFoundFilenames(java.lang.String[] filenames)
Set the names of all the files that we have found. |
java.lang.String |
toString()
Generate some useful info on this object. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean debug
protected java.lang.String folderName
protected java.lang.String[] filenameExtensions
protected java.lang.String[] foundFilenames
Constructor Detail |
---|
public FileSearch()
Method Detail |
---|
public java.lang.String[] getFoundFilenames()
public void setFoundFilenames(java.lang.String[] filenames)
filenames
- The names of all the
files that we have found.public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String[] getFilenameExtensions()
public java.lang.String getFilenameExtension(int index)
index
- Which filename extension do we want
to return. The first filename extension has an index
value of 0. The 2nd filename extension has an index
value of 1. etc.
public void setFilenameExtensions(java.lang.String[] filenameExtensions)
filenameExtensions
- The filename extensions that are we searching for.public java.lang.String getFolderName()
public void setFolderName(java.lang.String folderName)
name
- The name of the folder we are going to search.public void doStart()
protected java.lang.String[] searchFolderForFilenamesWithExtensions(java.lang.String folderName, java.lang.String[] extensions)
folderName
- The name of the folder
we are going to searchextensions
- A list of all the extensions
we are searching for. If a filename ends with
one of these extensions then the name of that
file will be included in the Vector of filenames
that is returned.
protected java.util.Vector searchFolderForFilenamesWithExtensions(java.lang.String folderName, java.lang.String[] extensions, java.util.Vector namesOfFoundFiles)
folderName
- The name of the folder
we are going to searchextensions
- A list of all the extensions
we are searching for. If a filename ends with
one of these extensions then the name of that
file will be included in the Vector of filenames
that is returned.namesOfFoundFiles
- A vector that contains the
names of all the files we have already found. If we
find any more files with the correct filename extension,
then we will add the name of that file to this vector.
protected boolean filenameEndsWithOneOfTheseExtensions(java.lang.String filename, java.lang.String[] extensions)
filename
- extensions
-
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |