Package ucar.unidata.util
Class IOUtil
java.lang.Object
ucar.unidata.util.IOUtil
A set of io related utilities
- Version:
- $Revision: 1.52 $
- Author:
- IDV development group.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
FileViewer is used to walk dir treesstatic class
Wrapper for a file for doing comparisonsstatic interface
UserAccountManager _more_ -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic boolean
debug flagstatic final int[]
Elements within this array are considered "valid redirect" status codes.static final int
HTTP connection timeout (milliseconds).static final int
Maximum number of HTTP redirects to follow. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
cleanFileName
(String name) Remove illegal characters in the given filenamestatic void
close
(InputStream inputStream) _more_static void
close
(OutputStream outputStream) _more_static void
Copy from file to to filestatic void
copyFile
(InputStream fis, File to) Copy from inputstream to to filestatic byte[]
createChecksum
(String filename) _more_static void
deleteDirectory
(File root) This will recursively delete all contents under the given directory.deleteFiles
(List<File> files) This deletes the files in the given list.findFilesToScour
(File dir, double hours, long maxBytes) This finds and returns a list files to scourgetDirectories
(File dir, boolean recurse) Recursively descend (if recurse is true) through the given directory and return a list of all subdirectories.getDirectories
(List dirs, boolean recurse) Recursively descend (if recurse is true) through the given directories and return a list of all subdirectories.static String
Return the file extension from the given file (including the ".").static String
Excise the filename from the given path and return the root.Recursively descend (if recurse is true) through the given directory and return a list of all filesRecursively descend (if recurse is true) through the given directory and return a list of all filesgetFiles
(List files, File dir, boolean recurse, PatternFileFilter filter) Recursively descend (if recurse is true) through the given directory and return a list of all filesstatic String
Gets the file name, removing any leading directory paths.static String
getFinalURL
(String urlStr) Return the String contents of the final url string.static InputStream
getInputStream
(String filename) Get an input stream for the filenamestatic InputStream
getInputStream
(String filename, Class origin) Get an input stream for the filenamestatic InputStream
getInputStreamOLDWAY
(String filename, Class origin) Get an input stream for the filenamegetListing
(String path, Class c) Lists the contents in the given file directory or java resource directorystatic String
_more_static String
getMD5Checksum
(String filename) _more_static File
getMostRecentFile
(File dir) Find the youngest file in the given directory.static File
getMostRecentFile
(File dir, FileFilter filter) Find the youngest file in the given directory that matches the givenFileFilter
.static File
getMostRecentFile
(File dir, FileFilter filter) Find the youngest file in the given directory that matches the givenFileFilter
.static File[]
getNormalFiles
(File[] files) Return an array of the file Files.static URL
Get an input stream for the filenamestatic URLConnection
getUrlConnection
(String url) Attempt to create aURLConnection
to the givenurl
.static URLConnection
getUrlConnection
(String url, boolean allowUserInteraction, boolean followRedirects, int timeout, int maxRedirects, int[] redirectStatuses) Attempt to create aURLConnection
to the givenurl
.static boolean
Does the given file or url have the given suffixstatic boolean
isADescendent
(File parent, File child) _more_static boolean
isHtmlFile
(String filenameOrUrl) Determine if the given filename is an html file.static boolean
isHtmlSuffix
(String url) Does the given url end with an html suffix.static boolean
isHttpProtocol
(String url) Is the given url an http protocol.static boolean
isImageFile
(String filename) Determine if the given filename is an image file (e.g., ends with .gif, .jpg, .jpeg, .png)static boolean
isRelativePath
(String path) Is the given path relativestatic boolean
isTextFile
(String filename) Determine if the given filename is a text file.static boolean
_more_static String
Return the String representation of the given filename joined to the given directory f1.static String
Return the String representation of the given filename joined to the given directory.static String
Return the String representation of the given path separated by args.static void
test mainpstatic String
If the directory defined in the given argument f does not exist then make it.static String
If the directory defined in the given argument path does not exist then make it.static final void
Make the directory.static double
millisToMinutes
(double millis) _more_static void
Move the from file to the to fileprotected static URLConnection
openConnection
(URL url) static void
pruneEmptyDirectories
(File root) This will recursively prune empty subdirectories of the given root directory.static void
pruneIfEmpty
(File root) This will recursively prune empty subdirectories of the given root directory.static byte[]
readBytes
(InputStream is) Read in the bytes from the given InputStream Closes the InputStream argument.static byte[]
readBytes
(InputStream is, Object loadId) Read in the bytes from the given InputStream Closes the InputStream argument.static byte[]
readBytes
(InputStream is, Object loadId, boolean closeIt) Read the bytes in the given input stream.static byte[]
readBytesAndCache
(String contentName, String cacheGroup) See if the content is in the perma-cache.static byte[]
readBytesAndCache
(String contentName, String cacheGroup, boolean unzipIfNeeded) See if the content is in the perma-cache.static String
readContents
(File file) Read the contents of aFile
.static String
Read in the bytes from the given InputStream and construct and return a String.static String
readContents
(String contentName) Return the String contents of the specified contentName.static String
readContents
(String contentName, Class origin) Return the String contents of the specified contentName.static String
readContents
(String contentName, Class origin, String dflt) Return the String contents of the specified contentName.static String
readContents
(String contentName, String dflt) Return the String contents of the specified contentName.static String
readContents
(URL url) _more_static String
Read in the bytes from the given InputStream and construct and return a String.static Object
readSerializedObject
(String file) _more_static void
_more_static File[]
sortFilesOnAge
(File[] files, boolean youngestFirst) Sort the given filesstatic File[]
sortFilesOnAge
(File directory, FileFilter filter, boolean youngestFirst) Sort the files contained by the given directory and that (if non-null) match the given filter.static IOUtil.FileWrapper[]
sortFilesOnAge
(IOUtil.FileWrapper[] files) _more_static File[]
sortFilesOnName
(File[] files) _more_static File[]
sortFilesOnName
(File[] files, boolean descending) _more_static String
Remove any file extension from the given file name.static void
testio()
_more_static File[]
Convert the toString value of the objects in the given files list to an array of File-sstatic void
Wait until there are new files in the given directory.static void
Wait until one or more of the files in the files list (File) has changed.static boolean
walkDirectory
(File dir, IOUtil.FileViewer fileViewer) Walk the dir tree with the given file viewerstatic boolean
walkDirectory
(File dir, IOUtil.FileViewer fileViewer, int level) Walk the dir tree with the given file viewerstatic FileFilter
wrapFilter
(FileFilter filter) Create a javaio FileFilter from the filechooser package file filter.static void
write
(OutputStream to, String s) Write the bytes held by the iven string to the outputstreamstatic void
writeBytes
(File filename, byte[] contents) Write out a file to theFile
specified.static void
Write out a file to theFile
specified.static void
Write out a file to the filename specified.static void
writeJarFile
(String filename, List files) Write out the list of files to the jar file specified by filenamestatic void
writeJarFile
(String filename, List files, String pathPrefix) Write out the list of files to the jar file specified by filenamestatic void
writeJarFile
(String filename, List files, String pathPrefix, boolean makeFilesUnique) Write out the list of files to the jar file specified by filenamestatic void
writeSerializedObject
(String file, Object o) _more_static long
writeTo
(InputStream from, OutputStream to) Copy the input stream to the output streamstatic long
writeTo
(InputStream from, OutputStream to, Object loadId, long length) Copy the input stream to the output streamstatic long
Write to the file from the URL streamstatic List
Copy the files pointed to by the urls list to the directory/file pointed to by prefx.static List
Copy the files pointed to by the urls list to the directory/file pointed to by prefx.static List
_more_
-
Field Details
-
MAX_REDIRECTS
public static final int MAX_REDIRECTSMaximum number of HTTP redirects to follow.- See Also:
-
HTTP_REDIRECT_STATUSES
public static final int[] HTTP_REDIRECT_STATUSESElements within this array are considered "valid redirect" status codes. -
HTTP_TIMEOUT
public static final int HTTP_TIMEOUTHTTP connection timeout (milliseconds).- See Also:
-
debug
public static boolean debugdebug flag
-
-
Constructor Details
-
IOUtil
public IOUtil()Default constructor; does nothing
-
-
Method Details
-
hasSuffix
Does the given file or url have the given suffix- Parameters:
fileOrUrl
- The name of the file or urlsuffix
- The suffix- Returns:
- Does the fileOrUrl have the suffix
-
getMostRecentFile
Find the youngest file in the given directory.- Parameters:
dir
- The directory to search in.- Returns:
- The most recent file (or null if none found).
-
getMostRecentFile
Find the youngest file in the given directory that matches the givenFileFilter
.- Parameters:
dir
- The directory to search in.filter
- TheFileFilter
to be used to limit what files we look at (may be null).- Returns:
- The most recent file (or null if none found).
-
sortFilesOnAge
Sort the files contained by the given directory and that (if non-null) match the given filter.- Parameters:
directory
- The directoryfilter
- The filteryoungestFirst
- Ascending or descending- Returns:
- The sorted files
-
getNormalFiles
Return an array of the file Files. That is, the ones where File.isFile is true- Parameters:
files
- Array of files- Returns:
- The files
-
sortFilesOnAge
Sort the given files- Parameters:
files
- The filesyoungestFirst
- Ascending or descending- Returns:
- Just return the given array
-
sortFilesOnAge
_more_- Parameters:
files
- _more_- Returns:
- _more_
-
deleteFiles
This deletes the files in the given list. It will return a list of those files where file.delete was not successful- Parameters:
files
- The files to delete- Returns:
- List of unsuccessfully deleted files
-
findFilesToScour
This finds and returns a list files to scour- Parameters:
dir
- _more_hours
- _more_maxBytes
- _more_- Returns:
- _more_
-
millisToMinutes
public static double millisToMinutes(double millis) _more_- Parameters:
millis
- _more_- Returns:
- _more_
-
sortFilesOnName
_more_- Parameters:
files
- _more_- Returns:
- _more_
-
sortFilesOnName
_more_- Parameters:
files
- _more_descending
- _more_- Returns:
- _more_
-
toFiles
Convert the toString value of the objects in the given files list to an array of File-s- Parameters:
files
- List of files- Returns:
- array of files
-
wrapFilter
Create a javaio FileFilter from the filechooser package file filter.- Parameters:
filter
- The filechooser file filter- Returns:
- The javaio FileFilter.
-
getMostRecentFile
Find the youngest file in the given directory that matches the givenFileFilter
.- Parameters:
dir
- The directory to search in.filter
- The filter to be used to limit what files we look at (may be null).- Returns:
- The most recent file (or null if none found).
-
writeTo
Copy the input stream to the output stream- Parameters:
from
- input streamto
- output- Returns:
- How may bytes were written
- Throws:
IOException
- On badness
-
write
Write the bytes held by the iven string to the outputstream- Parameters:
to
- stream to write tos
- string to write- Throws:
Exception
- on badness
-
readContents
_more_- Parameters:
url
- _more_- Returns:
- _more_
- Throws:
Exception
- _more_
-
getUrlConnection
Attempt to create aURLConnection
to the givenurl
.This method will follow redirects, and will use
HTTP_TIMEOUT
,MAX_REDIRECTS
, andHTTP_REDIRECT_STATUSES
as default values to pass togetUrlConnection(String, boolean, boolean, int, int, int[])
.- Parameters:
url
- Request URL.- Returns:
- Connection to
url
. - Throws:
IOException
- if there were any I/O errors while trying to connect.- See Also:
-
getUrlConnection
public static URLConnection getUrlConnection(String url, boolean allowUserInteraction, boolean followRedirects, int timeout, int maxRedirects, int[] redirectStatuses) throws IOException Attempt to create aURLConnection
to the givenurl
.If
followRedirects
istrue
, the maximum number of redirects is controlled viaMAX_REDIRECTS
. IffollowRedirects
isfalse
, the method, predictably, will not follow any redirects.- Parameters:
url
- Request URL.allowUserInteraction
- Passed toURLConnection.setAllowUserInteraction(boolean)
.followRedirects
- Whether or not HTTP redirect codes should be followed.timeout
- HTTP connection timeout (milliseconds).maxRedirects
- Maximum number of redirects to follow.redirectStatuses
- Status codes that are considered HTTP redirects.- Returns:
- Connection to
url
. - Throws:
IOException
- if there were any I/O errors while trying to connect.
-
writeTo
Write to the file from the URL stream- Parameters:
from
- URL for inputfile
- file for outputloadId
- A JobManager loadId that, if set, can be used to stop the load- Returns:
- number of bytes written
- Throws:
IOException
- problem writing to file.
-
writeTo
public static long writeTo(InputStream from, OutputStream to, Object loadId, long length) throws IOException Copy the input stream to the output stream- Parameters:
from
- input streamto
- outputloadId
- A JobManager loadId that, if set, can be used to stop the loadlength
- number of bytes to write- Returns:
- How may bytes were written
- Throws:
IOException
- On badness
-
writeTo
Copy the files pointed to by the urls list to the directory/file pointed to by prefx. We copy prefix0.suffix,prefix1.suffix, ..., prefixN.suffix- Parameters:
urls
- List of urls to copyprefix
- file directory prefixsuffix
- suffix- Returns:
- List of new files
- Throws:
IOException
- On badness
-
writeTo
public static List writeTo(List urls, String prefix, String suffix, Object loadId) throws IOException Copy the files pointed to by the urls list to the directory/file pointed to by prefx. We copy prefix0.suffix,prefix1.suffix, ..., prefixN.suffix- Parameters:
urls
- List of urls to copyprefix
- file directory prefixsuffix
- suffixloadId
- JobManager loadId- Returns:
- List of new files
- Throws:
IOException
- On badness
-
writeTo
public static List writeTo(List urls, String prefix, List suffixes, Object loadId) throws IOException _more_- Parameters:
urls
- _more_prefix
- _more_suffixes
- _more_loadId
- _more_- Returns:
- _more_
- Throws:
IOException
- _more_
-
getListing
Lists the contents in the given file directory or java resource directory- Parameters:
path
- may be a file directory path or a java resource directoryc
- base class to use if its java resources- Returns:
- List of sub files and directories
-
getFileTail
Gets the file name, removing any leading directory paths.- Parameters:
f
- The file path.- Returns:
- The file name.
-
getFileRoot
Excise the filename from the given path and return the root.- Parameters:
f
- The file path.- Returns:
- The file name.
-
stripExtension
Remove any file extension from the given file name.- Parameters:
f
- The file path.- Returns:
- The file name without the extension.
-
cleanFileName
Remove illegal characters in the given filename- Parameters:
name
- The filename to be cleaned up- Returns:
- The cleaned up filename
-
getFileExtension
Return the file extension from the given file (including the ".").- Parameters:
f
- The file path.- Returns:
- The file extension or an empty string if none found.
-
writeFile
public static void writeFile(String filename, String contents) throws FileNotFoundException, IOException Write out a file to the filename specified.- Parameters:
filename
- filename to write tocontents
- file contents- Throws:
FileNotFoundException
- if the file does not existIOException
- if there is a problem writing
-
writeFile
public static void writeFile(File filename, String contents) throws FileNotFoundException, IOException Write out a file to theFile
specified.- Parameters:
filename
- File to write tocontents
- file contents- Throws:
FileNotFoundException
- if the file does not existIOException
- if there is a problem writing
-
writeBytes
public static void writeBytes(File filename, byte[] contents) throws FileNotFoundException, IOException Write out a file to theFile
specified.- Parameters:
filename
- File to write tocontents
- file contents- Throws:
FileNotFoundException
- if the file does not existIOException
- if there is a problem writing
-
moveFile
Move the from file to the to file- Parameters:
from
- File to moveto
- The destination- Throws:
FileNotFoundException
- When we cannot find the fileIOException
- When something untoward happens
-
copyFile
Copy from file to to file- Parameters:
from
- File to copyto
- The destination- Throws:
FileNotFoundException
- When we cannot find the fileIOException
- When something untoward happens
-
copyFile
Copy from inputstream to to file- Parameters:
fis
- sourceto
- The destination- Throws:
FileNotFoundException
- When we cannot find the fileIOException
- When something untoward happens
-
isTextFile
Determine if the given filename is a text file. i.e., it ends with .txt or .text- Parameters:
filename
- The filename to check.- Returns:
- Is the filename a text file.
-
isImageFile
Determine if the given filename is an image file (e.g., ends with .gif, .jpg, .jpeg, .png)- Parameters:
filename
- The filename to check.- Returns:
- Is the filename an image file.
-
isHtmlFile
Determine if the given filename is an html file. i.e., it ends with .htm or .html or if it does not have a file extension and begins with http:- Parameters:
filenameOrUrl
- The filename to check.- Returns:
- Is the filename an html file.
-
isHtmlSuffix
Does the given url end with an html suffix.- Parameters:
url
- The url- Returns:
- Ends with html, htm, or shtml
-
isHttpProtocol
Is the given url an http protocol.- Parameters:
url
- The url- Returns:
- Starts with http or https
-
getInputStream
Get an input stream for the filename- Parameters:
filename
- name of file- Returns:
- corresponding input stream
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream
-
getInputStream
public static InputStream getInputStream(String filename, Class origin) throws FileNotFoundException, IOException Get an input stream for the filename- Parameters:
filename
- name of fileorigin
- relative origin point for file location- Returns:
- corresponding input stream
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream
-
openConnection
- Throws:
IOException
-
setUserAccountManager
_more_- Parameters:
manager
- _more_
-
getInputStreamOLDWAY
public static InputStream getInputStreamOLDWAY(String filename, Class origin) throws FileNotFoundException, IOException Get an input stream for the filename- Parameters:
filename
- name of fileorigin
- relative origin point for file location- Returns:
- corresponding input stream
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream
-
getURL
Get an input stream for the filename- Parameters:
filename
- name of fileorigin
- relative origin point for file location- Returns:
- corresponding input stream
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream
-
readContents
Read the contents of aFile
. Used for reading text type files (XML, HTML, etc)- Parameters:
file
- file to read.- Returns:
- contents as a String
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream
-
isADescendent
_more_- Parameters:
parent
- _more_child
- _more_- Returns:
- _more_
-
readContents
Return the String contents of the specified contentName. If the read fails (for whatever reason) then return the dflt parameter- Parameters:
contentName
- URL or filenamedflt
- default to return if a problem- Returns:
- contents or default value
-
readContents
Return the String contents of the specified contentName. If the read fails (for whatever reason) then return the dflt parameter- Parameters:
contentName
- URL or filenameorigin
- origin classdflt
- default to return if a problem- Returns:
- contents or default value
-
readContents
Return the String contents of the specified contentName.- Parameters:
contentName
- can either be a URL, a filename or a resource.- Returns:
- contents or
null
if there is a problem. - Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem reading contents
-
isRelativePath
Is the given path relative- Parameters:
path
- file path- Returns:
- is relative
-
readContents
public static String readContents(String contentName, Class origin) throws FileNotFoundException, IOException Return the String contents of the specified contentName. contentName can either be a URL, a filename or a resource.- Parameters:
contentName
- can either be a URL, a filename or a resource.origin
- relative origin for path to file- Returns:
- contents or
null
if there is a problem. - Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem reading contents
-
getFinalURL
Return the String contents of the final url string.- Parameters:
urlStr
- can be a URL .- Returns:
- contents or
null
if there is a problem.
-
readBytesAndCache
public static byte[] readBytesAndCache(String contentName, String cacheGroup) throws FileNotFoundException, IOException See if the content is in the perma-cache. If it is then return it. Else read it (e.g., from a url) and cache it.- Parameters:
contentName
- url or filenamecacheGroup
- Cache group- Returns:
- Bytes read
- Throws:
FileNotFoundException
- On badnessIOException
- On badness
-
isZipFile
_more_- Parameters:
file
- _more_- Returns:
- _more_
-
readBytesAndCache
public static byte[] readBytesAndCache(String contentName, String cacheGroup, boolean unzipIfNeeded) throws FileNotFoundException, IOException See if the content is in the perma-cache. If it is then return it. Else read it (e.g., from a url) and cache it.- Parameters:
contentName
- url or filenamecacheGroup
- Cache groupunzipIfNeeded
- IF true and if the url is a zip file then unzip it- Returns:
- Bytes read
- Throws:
FileNotFoundException
- On badnessIOException
- On badness
-
readContents
Read in the bytes from the given InputStream and construct and return a String. Closes the InputStream argument.- Parameters:
is
- InputStream to read from- Returns:
- contents as a String
- Throws:
IOException
- problem reading contents
-
readInputStream
Read in the bytes from the given InputStream and construct and return a String. Closes the InputStream argument.- Parameters:
is
- InputStream to read from- Returns:
- contents as a String
- Throws:
IOException
- problem reading contents
-
readBytes
Read in the bytes from the given InputStream Closes the InputStream argument.- Parameters:
is
- InputStream to read from- Returns:
- bytes read
- Throws:
IOException
- problem reading contents
-
readBytes
Read in the bytes from the given InputStream Closes the InputStream argument. The globalTimestamp and myTimestamp parameters, if non-null, allow calling routines to abort the read. globalTimestamp, if non-null, is a array of size one that holds a virtual timestamp. If at anytime during the read of the bytes the value in globalTimestamp is different then the value given for myTimestamp then the read is aborted and null is returned.- Parameters:
is
- InputStream to read fromloadId
- Job manager load id- Returns:
- bytes read
- Throws:
IOException
- problem reading contents
-
close
_more_- Parameters:
inputStream
- _more_
-
close
_more_- Parameters:
outputStream
- _more_
-
readBytes
Read the bytes in the given input stream.- Parameters:
is
- The input streamloadId
- If non-null check with the JobManager if we should continuecloseIt
- If true then close the input stream- Returns:
- The bytes
- Throws:
IOException
- On badness
-
joinDir
Return the String representation of the given filename joined to the given directory.- Parameters:
f1
- directory pathf2
- filename- Returns:
- concatenated String with the appropriate file separator
-
joinDir
Return the String representation of the given filename joined to the given directory f1.- Parameters:
f1
- directory pathfilename
- filename- Returns:
- concatenated String with the appropriate file separator
-
joinDirs
Return the String representation of the given path separated by args.- Parameters:
f
- directory path vararg- Returns:
- concatenated String with the appropriate file separator
-
makeDir
If the directory defined in the given argument path does not exist then make it.- Parameters:
path
- directory to make- Returns:
- the directory path
-
makeDir
If the directory defined in the given argument f does not exist then make it.- Parameters:
f
- directory as a file- Returns:
- directory path
-
makeDirRecursive
Make the directory. This will recurse and make the directory tree if needed- Parameters:
f
- directory to make
-
getFiles
Recursively descend (if recurse is true) through the given directory and return a list of all files- Parameters:
dir
- The directory to look atrecurse
- Do we recurse- Returns:
- List of files
-
getFiles
Recursively descend (if recurse is true) through the given directory and return a list of all files- Parameters:
files
- The list of files to add todir
- The directory to look atrecurse
- Do we recurse- Returns:
- List of files
-
getFiles
Recursively descend (if recurse is true) through the given directory and return a list of all files- Parameters:
files
- The list of files to add todir
- The directory to look atrecurse
- Do we recursefilter
- If non-null then use this to find files- Returns:
- List of files
-
walkDirectory
Walk the dir tree with the given file viewer- Parameters:
dir
- dirfileViewer
- viewer- Returns:
- should continue
- Throws:
Exception
- on badness_
-
walkDirectory
public static boolean walkDirectory(File dir, IOUtil.FileViewer fileViewer, int level) throws Exception Walk the dir tree with the given file viewer- Parameters:
dir
- dirfileViewer
- viewerlevel
- tree depth- Returns:
- should continue
- Throws:
Exception
- on badness_
-
getDirectories
Recursively descend (if recurse is true) through the given directory and return a list of all subdirectories.- Parameters:
dir
- The directory to look atrecurse
- Do we recurse- Returns:
- List of subdirs (File)
-
getDirectories
Recursively descend (if recurse is true) through the given directories and return a list of all subdirectories.- Parameters:
dirs
- List of directories to look atrecurse
- Do we recurse- Returns:
- List of subdirs (File)
-
pruneIfEmpty
This will recursively prune empty subdirectories of the given root directory. It will delete the given root directory if it is empty.- Parameters:
root
- Directory to prune
-
pruneEmptyDirectories
This will recursively prune empty subdirectories of the given root directory. It will NOT delete the given root directory if it is empty.- Parameters:
root
- Directory to prune
-
deleteDirectory
This will recursively delete all contents under the given directory.- Parameters:
root
- Directory to delete
-
wait
Wait until there are new files in the given directory. If filePattern is non null then use that (regular expression) to match the files.- Parameters:
directory
- The directoryfilePattern
- The patternsleepSeconds
- Sleep this number of seconds between each check
-
wait
Wait until one or more of the files in the files list (File) has changed. If the files list is null or empty then just return.- Parameters:
files
- List of File-ssleepSeconds
- Seconds to sleep between checks.
-
readSerializedObject
_more_- Parameters:
file
- _more_- Returns:
- _more_
- Throws:
Exception
- _more_
-
writeSerializedObject
_more_- Parameters:
file
- _more_o
- _more_- Throws:
Exception
- _more_
-
testio
_more_- Throws:
Exception
- _more_
-
main
test mainp- Parameters:
args
- cmd line args- Throws:
Exception
- On badness
-
writeJarFile
Write out the list of files to the jar file specified by filename- Parameters:
filename
- jar file namefiles
- list of files- Throws:
IOException
- On badness
-
writeJarFile
Write out the list of files to the jar file specified by filename- Parameters:
filename
- jar file namefiles
- list of filespathPrefix
- If not null this is the prefx we add to the jar entry- Throws:
IOException
- On badness
-
writeJarFile
public static void writeJarFile(String filename, List files, String pathPrefix, boolean makeFilesUnique) throws IOException Write out the list of files to the jar file specified by filename- Parameters:
filename
- jar file namefiles
- list of filespathPrefix
- If not null this is the prefx we add to the jar entrymakeFilesUnique
- If true then make all of the file names unique in case of conflict- Throws:
IOException
- On badness
-
createChecksum
_more_- Parameters:
filename
- _more_- Returns:
- _more_
- Throws:
Exception
- _more_
-
getMD5Checksum
_more_- Parameters:
filename
- _more_- Returns:
- _more_
- Throws:
Exception
- _more_
-
getMd5
_more_- Parameters:
path
- _more_- Returns:
- _more_
- Throws:
Exception
- _more_
-