Modifier and Type | Field and Description |
---|---|
private static String |
CLASSNAME
A holder This classes name (used when logging).
|
static String |
CLASSPATH
The VM classpath (used in some methods)..
|
static short |
DEFAULT_LOOKANDFEEL
the Default LookAndFeel CONSTANT.
|
static Vector |
errorFiles_
The collection of filenames that had errors during compression.
|
(package private) static String[] |
hex |
private static boolean |
initUtil
Class flag signifying if the initUtil method has been called
|
private static Log |
log_
Gets a Log instance in case any calling classes are using it.
|
static short |
MAC_LOOKANDFEEL
the Mac LookAndFeel CONSTANT.
|
static String |
macClassName
the Mac LookAndFeel class name
|
static short |
METAL_LOOKANDFEEL
the Metal LookAndFeel CONSTANT.
|
static String |
metalClassName
the Java LookAndFeel class name
|
static short |
MOTIF_LOOKANDFEEL
the Motif LookAndFeel CONSTANT.
|
static String |
motifClassName
the motif LookAndFeel class name
|
static short |
OPEN_DIALOG
A constant to specify which dialog to open with the chooseFileDialog.
|
static short |
SAVE_DIALOG
A constant to specify which dialog to open with the chooseFileDialog.
|
static String |
SYSTEM_FILE_SEPERATOR
A holder for this clients System File Separator.
|
static String |
SYSTEM_LINE_SEPERATOR
A holder for this clients System line termination separator.
|
static String |
USERDIR
The users pwd ditrectory.
|
static String |
USERHOME
The users home ditrectory.
|
static boolean |
watchdogReset
Class flag for the threadWatchdog method to enable the calling user
to stop the watch.
|
static String |
windowsClassName
the Windoze LookAndFeel class name
|
static short |
WINDOZE_LOOKANDFEEL
the Windoze LookAndFeel CONSTANT.
|
static String |
zippedOutputLocation_
The temp dir where the zipped files go before archiving.
|
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static String |
absoluteToPwdRelativePath(File absPath)
Converts an Absolute path to a relative path from the VM Working Dir.
|
static String |
absoluteToPwdRelativePath(String absPath)
Converts an Absolute path to a relative path from the VM Working Dir.
|
private static void |
addDirToArchive(ZipOutputStream zos,
File srcFile,
String rootDir)
Simple recursive method that takes a Directory File and pumps its files into the passed in zip.
|
static String |
appendStringToFile(String s,
String fileName)
Abstracts the appending of string to a file and creates it if not already there.
|
static String |
capsToSpacesInString(String fName)
Takes a string and adds a space in front of any capitalized char.
|
static String |
capsToUndersInString(String fName)
Takes a string and adds a space in front of any capitalized char.
|
static String |
chooseAFilename(Component parent,
String startPath)
Encapsulates the showing of the FileChooser dialog and returns a String
representing the absolute path.
|
static String |
chooseAFilename(Component parent,
String startPath,
ExampleFileFilter[] filters,
boolean filesAndDirs)
Encapsulates the showing of the FileChooser dialog and returns a String
representing the absolute path.
|
static String |
chooseAFilename(Component parent,
String startPath,
ExampleFileFilter[] filters,
boolean filesAndDirs,
short openOrClose)
Encapsulates the showing of the FileChooser dialog and returns a String
representing the absolute path.
|
static String |
compressDirFilesWithZip(String inDirName,
String zipFilename)
Abstracts the compressing of all files in a dir with zip format - simply takes the dirFiles and wraps it whole into a zip file.
|
static String |
compressFileWithZip(String inFilename)
Abstracts the compressing of a file with zip format - simly takes the file and wraps it whole into a zip file.
|
static String |
compressFileWithZip(String inFilename,
String zipFilename)
Abstracts the compressing of a file with zip format - simly takes the file and wraps it whole into a zip file.
|
static String |
computeMD5Sum(String input)
Uses Java to compute the MD5 sum of a given input String.
|
static int |
convertHexNumberStringToDecimal(String str)
Converts an HEX number String to its decimal equivalent.
|
static int |
convertHexNumberStringToDecimal(String str,
boolean dumpOut)
Converts an HEX number String to its decimal equivalent.
|
static String |
convertHexToString(String hex)
Converts a hex String to an ascii String
|
static String |
convertStringToHex(String str)
Converts an ascii String to a hex String
|
static void |
copyFile(String from,
String to)
Helper method to copy a file
|
static long |
countFilesInDir(String dirName,
boolean recurse)
Counts the files in a dir (optionally recurses sub dirs)
|
static String |
createCurrentDateStamp()
Creates a timestamp for the current date.
|
static String |
createCurrentDateTime()
Creates a timestamp for the current date.
|
static String |
createCurrentDateTimeStamp()
Creates a timestamp for the current date and time.
|
static String |
createCurrentTimeStamp()
Creates a timestamp for the current time in the form of 'hour + "-" + min
+ "-" + sec + "-" + millis'.
|
static String |
createTimerTimeStamp(int startTimeMillis)
Creates a Timer timestamp from the current time to the passed startTime
in the form of
'hour + "-" + min + "-" + sec + "-" + millis'. |
static String |
csvToJSON(String content,
String separator) |
static String |
decimalToBinary(int s)
A simple int to Binary String converter.
|
static String |
decimalToHexadecimal(int s)
Another simple int to Hex String converter.
|
static String |
decodeURL(String s) |
static long |
dirSize(String fileName,
boolean recurseSubdirs)
Obtains the bytes of data contained in all files in this dir
(and subdirs).
|
static long |
dirSize2(String fileName,
boolean recurseSubdirs)
Using the new NIO classes, obtains the bytes of data contained in all files in this dir
(and subdirs).
|
static long |
dirSizeOld(String fileName,
boolean recurseSubdirs)
Obtains the bytes of data contained in all files in this dir
(and subdirs).
|
static String |
encodeToURL(String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced
with the UTF-8-in-URL proposal.
|
static void |
ensureFolderExists(File folder) |
static void |
ensureFolderExists(String foldername) |
static void |
ensureParentFolderExists(File folder)
Ensures that a folder exists.
|
static void |
ensureParentFolderExists(String foldername) |
static String |
executeNativeApp(String executableLocation,
String[] cmds,
boolean verboseOutput)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static String |
executeNativeApp(String executableLocation,
String[] cmds,
boolean verboseOutput,
String workingDir)
Executes the Specified Native OS application with the provided commandline
parameters and Working Directory.
|
static int |
executeNativeApp(String executableLocation,
String[] cmds,
String outFilename,
boolean verboseOutput)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static int |
executeNativeApp(String executableLocation,
String[] cmds,
String outFilename,
StreamGobbler inputGobbler,
boolean verboseOutput,
String workingDir)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static String |
executeNativeApp(String executableLocation,
Vector appParms,
boolean verboseOutput)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static String |
executeNativeApp(String executableLocation,
Vector appParms,
boolean verboseOutput,
String workingDir)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static int |
executeNativeApp(String executableLocation,
Vector appParms,
String outFilename)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static int |
executeNativeApp(String executableLocation,
Vector appParms,
String outFilename,
boolean verboseOutput)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static int |
executeNativeApp(String executableLocation,
Vector appParms,
String outFilename,
StreamGobbler inputGobbler,
boolean verboseOutput)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static int |
executeNativeApp(String executableLocation,
Vector appParms,
String outFilename,
StreamGobbler inputGobbler,
boolean verboseOutput,
String workingDir)
Executes the Specified Native OS application with the provided commandline
parameters.
|
static Vector |
findFile(String fileName,
String directory,
boolean recurseSubdirs,
boolean regExp,
boolean verbose)
Searches the provided directory (and subdirs) for the requested file.
|
static Frame |
getAncestorFrame(Component c)
This method seeks out and returns the Parent Frame for a given component.
|
static String |
getCurrentClassName()
Returns the calling classes name.
|
static Date |
getCurrentDate()
gets the current date and time.
|
static String |
getCurrentMethodName()
Returns the calling methods name.
|
static URL |
getFileBaseURL(String fileString)
Creates a URL for the specified filename string.
|
static URL[] |
getFileBaseURLs(String[] fileStrings)
Creates a URL[] for the given Strings.
|
static File |
getFileDir(String fileString)
Creates a File representing the Dir for the specified filename string.
|
static String |
getFileDirStr(String fileString)
Gets a string representing the Dir for the specified filename string.
|
static String |
getFilePathFromClasspath(String filename)
Searches the classpath for the specified filename and then returns the
full path that is used for it.
|
static String |
getFilePathFromClasspath(String filename,
String fallBack)
Searches the classpath for the specified filename and then returns the
full path that is used for it.
|
static InetAddress |
getLocalhostName()
gets the current VMs localhost address.
|
static File |
initDirFile(String s)
Initisalizes File only if it is directory.It is represented by the passed
in String.
|
private static void |
initUtil()
Inits the log and some other vars.
|
static String |
left(String value,
int numChars)
Gives you the leftmost number of chars in a string.
|
static Icon |
loadIcon(String name)
Abstracts the loading of a resource image file from ca.bc.webarts.resources.images as an icon.
|
static Icon |
loadIcon(String resourcePackageName,
String name)
Abstracts the loading of a resource image file as an icon.
|
static Image |
loadImage(String imageFilename)
Loads the requested Image filename from the classpath.
|
static Image |
loadImage(String imageFilename,
String jarFilename)
Loads the requested Image filename from the specified jarfile.
|
static void |
main(String[] args) |
static boolean |
moveFile(String filename,
String foldername)
Moves the specified file to the specified directory.
|
static String |
readFileToString(String fileName)
Abstracts the reading of a file and returns the contents as a String.
|
static long |
recursiveBzip2(File fo)
Wrapper method to accept a dir or individual file in the passed in File
object AND then calls the method that writes the passed file/dir to this
MultiZip instances zip output stream.
|
static boolean |
removeDir(String fileName)
Recursively deletes all the files in the spec'd directory and
subdirectories, and then removes the dir.
|
static boolean |
removeFile(String fileName)
Deletes a file.
|
static boolean |
removeOldFiles(String dirName,
int numDays,
boolean recurse)
Deletes all files in the spec'd dir that are older than the spec'd
number of days.
|
static String |
removeParentRelativeReference(String path)
Removes a '/..' from the filename string and returns the corrected dir
name reference.
|
static String |
renameFile(String fromFilename,
String toFilename)
Renames the specified file to the toFilename in the same directory.
|
static String |
right(String value,
int numChars)
Gives you the rightmost number of chars in a string.
|
static String[] |
searchInFile(String searchStr,
String filename,
boolean verbose)
Searches the provided file for the search String.
|
static Hashtable |
searchInFile(String searchStr,
String filename,
boolean recurseSubdirs,
boolean fileRegExp,
boolean verbose)
Searches the provided file/directory (and subdirs) for the search String.
|
static void |
setIconForApp(JFrame appFrame,
String imageFilename)
SetsIcon for the passed in Frame
|
static void |
setIconForApp(JFrame appFrame,
URL imageUrl)
SetsIcon for the passed in Frame
|
static void |
setTheLookAndFeel(short i,
Component comp)
Calls the User Interface Manager and sets the look and feel setting based
on the parameter it is passed.
|
static boolean |
sleep(long waitTime)
A method to simply abstract the Try/Catch required to put the current
thread to sleep for the specified time in ms.
|
static ArrayList<Set<Map.Entry<String,Integer>>> |
sortByValues(Hashtable<String,Integer> hIn)
A method to simply sort a Hashtable holding a String key & Integer values) by its Highest To Lowest values
then alphabetical (low to high) for the keys.
|
static ArrayList<Set<Map.Entry<String,Integer>>> |
sortByValues(Hashtable<String,Integer> hIn,
boolean ascendingOrder)
A method to simply sort a Hashtable(holding a String key & Integer values) by its Integer values
then by its String keys.
|
static void |
spacesToCapsInDir(String dirName)
Renames files to a more URL friendly format.
|
static void |
spacesToCapsInDir(String dirName,
boolean doUnderscores)
Renames files to a more URL friendly format.
|
static void |
spacesToCapsInDir(String dirName,
boolean doUnderscores,
boolean verboseOut)
Renames files to a more URL friendly format.
|
static String |
spacesToCapsInFileName(String fName)
Removes any space chars ' ' from a filename and Capitalizes the next char.
|
static String |
spacesToCapsInString(String fName)
Removes any space chars ' ' from a String and Capitalizes the next char.
|
static String |
spacesToCapsInString(String fName,
boolean includeUnderscore)
Removes any space chars ' ' from a String and Capitalizes the next char.
|
static double |
sphereDistanceBetween(double lat1,
double lng1,
double lat2,
double lng2)
Calculates the Distance in meters between two LatLong points on the earth assuming it is a perfect sphere.
|
static boolean |
threadWatchdog(Thread watchThread,
long timeToTerminate)
A Thread Watchdog that watches the passed in thread and Interupts it if it
has not finished by the requested time.
|
static char[] |
toHEXChars(int num)
A simple int to Hex String converter.
|
static char[] |
toHEXChars(int num,
int paddedLength)
A simple int to Hex String converter.
|
static String |
toHEXString(byte b)
A simple byte to Hex String converter.
|
static String |
toHEXString(int s)
A simple int to Hex String converter.
|
static String |
tokenReplace(String sentence,
String token,
String replacement)
A simple String token replacement routine.
|
static void |
tokenReplaceInFile(String file,
String token,
String value)
Token replace method for a given filename (NO recursion) and then saves the file with the
swapped tokens.
|
static void |
tokenReplaceInFile(String file,
String token,
String value,
boolean recurseSubdirs)
Token replace method for a given filename (and optional recusion into subdirs) and then saves the file with the
swapped tokens.
|
static String |
writeStringToFile(ByteArrayInputStream inputStream,
String fileName)
Abstracts the writing of an InputSteam to a file.
|
static String |
writeStringToFile(InputStream inputStream,
String fileName)
Abstracts the writing of an InputSteam to a file.
|
static String |
writeStringToFile(String s,
String fileName)
Abstracts the writing of string to a file.
|
static String |
writeStringToFile(String s,
String fileName,
boolean zipCompress)
Abstracts the writing of string to a (zip) file (Zip NOT IMPLEMENTED YET).
|
static String |
xmlToPrettyString(String xmlString,
int indent) |
public static final String SYSTEM_FILE_SEPERATOR
public static final String SYSTEM_LINE_SEPERATOR
public static final short OPEN_DIALOG
public static final short SAVE_DIALOG
public static final short METAL_LOOKANDFEEL
public static final short WINDOZE_LOOKANDFEEL
public static final short MOTIF_LOOKANDFEEL
public static final short MAC_LOOKANDFEEL
public static final short DEFAULT_LOOKANDFEEL
public static String macClassName
public static String metalClassName
public static String motifClassName
public static String windowsClassName
private static boolean initUtil
public static boolean watchdogReset
public static String zippedOutputLocation_
public static Vector errorFiles_
public Util()
private static void initUtil()
public static void ensureParentFolderExists(File folder)
Description: use it like this: ensureFolderExists(new File(fileName).getParentFile()); |
folder
- The File object to check.public static void ensureFolderExists(File folder)
public static void ensureParentFolderExists(String foldername)
public static void ensureFolderExists(String foldername)
public static String renameFile(String fromFilename, String toFilename)
fromFilename
- is the absoulte pathname of the file to rename.toFilename
- is the new filename.public static boolean moveFile(String filename, String foldername)
filename
- is the absoulte pathname of the file to move.foldername
- is the directory to move it to.public static int convertHexNumberStringToDecimal(String str)
str
- holding the Hex Number string to convert to decimalpublic static int convertHexNumberStringToDecimal(String str, boolean dumpOut)
str
- holding the Hex Number string to convert to decimaldumpOut
- boolean flag to turn some debug output on/offpublic static String convertStringToHex(String str)
public static String convertHexToString(String hex)
public static String toHEXString(byte b)
b
- The byte to convertpublic static final String toHEXString(int s)
s
- The int to convertpublic static final char[] toHEXChars(int num)
num
- The int to convertpublic static final char[] toHEXChars(int num, int paddedLength)
num
- The int to convertpublic static final String decimalToHexadecimal(int s)
s
- The int to convertpublic static final String decimalToBinary(int s)
s
- The int to convertpublic static String computeMD5Sum(String input)
input
- is the string to computepublic static String xmlToPrettyString(String xmlString, int indent) throws Exception
Exception
public static void setIconForApp(JFrame appFrame, String imageFilename)
imageFilename
- - is the filename for the new iconappFrame
- The new iconForApp valuepublic static void setIconForApp(JFrame appFrame, URL imageUrl)
imageUrl
- - is the URL for the new iconappFrame
- The new iconForApp valuepublic static String createCurrentDateTime()
public static String createCurrentDateStamp()
public static String createCurrentDateTimeStamp()
public static String createCurrentTimeStamp()
public static String createTimerTimeStamp(int startTimeMillis)
public static String getCurrentClassName()
public static String getCurrentMethodName()
public static String tokenReplace(String sentence, String token, String replacement)
sentence
- The String to perform the token replacement ontoken
- the token String to seartch for and replacereplacement
- the tokens replacement valuepublic static boolean removeDir(String fileName)
fileName
- The filename of the directory to delete.public static boolean removeFile(String fileName)
fileName
- The filename to delete.public static boolean removeOldFiles(String dirName, int numDays, boolean recurse)
dirName
- The directory to parse for files to delete.numDays
- The age of the files to delete.recurse
- Do the removal recursively.public static long dirSizeOld(String fileName, boolean recurseSubdirs)
fileName
- The filename of the directory .public static long dirSize(String fileName, boolean recurseSubdirs)
fileName
- The filename of the directory .public static long dirSize2(String fileName, boolean recurseSubdirs)
fileName
- The filename of the directory .recurseSubdirs
- include the subDirs in the result.public static void copyFile(String from, String to) throws IOException
from
- the from filenameto
- the to filenameIOException
public static void tokenReplaceInFile(String file, String token, String value)
file
- The file(name) to act ontoken
- The search token (that will get replaced)value
- The replacement string.public static void tokenReplaceInFile(String file, String token, String value, boolean recurseSubdirs)
file
- The file(name) to act ontoken
- The search token (that will get replaced)value
- The replacement string.public static String compressFileWithZip(String inFilename)
s
- is the String to writeoutinFilename
- is the file name of the file to write the String intopublic static String compressFileWithZip(String inFilename, String zipFilename)
inFilenames
- is the input file to zip upzipFilename
- is the file name of the resulting zipfilepublic static long recursiveBzip2(File fo)
fo
- The File object to zip up (can be an actual file or dir).public static String compressDirFilesWithZip(String inDirName, String zipFilename)
inDirName
- is the input dir to source the files from to zip upzipFilename
- is the file name of the resulting zipfileprivate static void addDirToArchive(ZipOutputStream zos, File srcFile, String rootDir) throws IOException
String inDirName = "c:\Users\JoeBlo\Docs\work\ProjectA"; File dirFile = new File(inDirName); String zipFilename = "ProjectA_files.zip"; FileOutputStream fos = new FileOutputStream(zipFilename); ZipOutputStream zos = new ZipOutputStream(fos); // get the root part of the path to the file to zip up // gets "c:\Users\JoeBlo\Docs\work" String rootDirStr = dirFile.getAbsolutePath().substring(0,dirFile.getAbsolutePath().indexOf(dirFile.getName())); // create a zip with the files within 'dirFile' inside it addDirToArchive(zos, dirFile, rootDirStr); zos.close();
zos
- is the already created ZipOutputStream to add tosrcFile
- is the Directory File to zip up its contained filesrootDir
- the root path that will be chopped off the front of the embedded file paths so everything ends up in a nice root of the zip file.IOException
public static Icon loadIcon(String name)
name
- is the file name of the file to readpublic static Icon loadIcon(String resourcePackageName, String name)
name
- is the file name of the file to readpublic static String writeStringToFile(InputStream inputStream, String fileName)
fileName
- is the file name of the file to write the String intopublic static String writeStringToFile(ByteArrayInputStream inputStream, String fileName)
fileName
- is the file name of the file to write the String intopublic static String appendStringToFile(String s, String fileName)
s
- is the String to writeoutfileName
- is the file name of the file to write the String intopublic static String writeStringToFile(String s, String fileName)
s
- is the String to writeoutfileName
- is the file name of the file to write the String intopublic static String writeStringToFile(String s, String fileName, boolean zipCompress)
s
- is the String to writeoutfileName
- is the file name of the file to write the String intozipCompress
- boolean fall to compress with zip compressionpublic static String readFileToString(String fileName)
fileName
- is the file naem to read into a Stringpublic static String[] searchInFile(String searchStr, String filename, boolean verbose)
searchStr
- The searchString/regexp to search for.filename
- The filename to search through.verbose
- true will produce output to System.out just like the
UNIX find cmdpublic static Hashtable searchInFile(String searchStr, String filename, boolean recurseSubdirs, boolean fileRegExp, boolean verbose)
searchStr
- The searchString/regexp to search for.filename
- The filename/directoryName to search through.recurseSubdirs
- Flags if the sub-dirs are searched.fileRegExp
- Flags if 'fileName' should be regarded as a regular
expression.verbose
- true will produce output to System.out just like the
UNIX find cmdpublic static Vector findFile(String fileName, String directory, boolean recurseSubdirs, boolean regExp, boolean verbose)
fileName
- The filename/regexp to search for.directory
- The filename of the directory to delete.recurseSubdirs
- Flags if the sub-dirs are searched.regExp
- Flags if 'fileName' should be regarded as a regular
expression.verbose
- true will produce output to System.out just like the
UNIX find cmdpublic static File initDirFile(String s)
s
- the directory name to init as a Filepublic static void spacesToCapsInDir(String dirName)
It goes through each file in the specified directory and renames them using the spacesToCapsInFileName method of renaming.
spacesToCapsInFileName(String)
,
#dirFile
public static void spacesToCapsInDir(String dirName, boolean doUnderscores)
It goes through each file in the specified directory and renames them using the spacesToCapsInFileName method of renaming.
spacesToCapsInFileName(String)
,
#dirFile
public static void spacesToCapsInDir(String dirName, boolean doUnderscores, boolean verboseOut)
It goes through each file in the specified directory and renames them using the spacesToCapsInFileName method of renaming.
spacesToCapsInFileName(String)
,
#dirFile
public static String spacesToCapsInFileName(String fName)
NOTE: The file is expected to be in the current working directorydirectory
fName
- a string representing the file to perform the actionpublic static String spacesToCapsInString(String fName)
fName
- a string perform the actionpublic static String spacesToCapsInString(String fName, boolean includeUnderscore)
fName
- a string perform the actionincludeUnderscoreflag
- if '_' are also removedpublic static String capsToSpacesInString(String fName)
fName
- a string perform the actionpublic static String capsToUndersInString(String fName)
fName
- a string perform the actionpublic static String right(String value, int numChars)
value
- is the string to pull result fromnumChars
- the number of chars to return from the right side of 'value'public static String left(String value, int numChars)
value
- is the string to pull result fromnumChars
- the number of chars to return from the left side of 'value'public static String getFilePathFromClasspath(String filename, String fallBack)
filename
- to look for in the classpathfallBack
- if the file is not found in classpathpublic static String getFilePathFromClasspath(String filename)
filename
- the filename to look forpublic static Frame getAncestorFrame(Component c)
c
- The Component to be used as the basis of the frame searchpublic static void setTheLookAndFeel(short i, Component comp)
i
- The new TheLookAndFeel valuepublic static Image loadImage(String imageFilename, String jarFilename)
imageFilename
- the filename in the jarfile to use as the basis for
the Image to retrieve.jarFilename
- the jar file to look through for the image.public static Image loadImage(String imageFilename)
imageFilename
- the filename in the jarfile to use as the basis for
the Image to retrieve.public static boolean sleep(long waitTime)
waitTime
- the sleep time in milli seconds (ms).public static ArrayList<Set<Map.Entry<String,Integer>>> sortByValues(Hashtable<String,Integer> hIn)
hIn
- the original hashtable to sort.public static ArrayList<Set<Map.Entry<String,Integer>>> sortByValues(Hashtable<String,Integer> hIn, boolean ascendingOrder)
hIn
- the original hashtable to sort.public static String chooseAFilename(Component parent, String startPath)
NO file filters will be used and NO directory selection is allowed.
parent
- the owner of this dialog (generally just send this)startPath
- the dir to start the file chooser dialog frompublic static String chooseAFilename(Component parent, String startPath, ExampleFileFilter[] filters, boolean filesAndDirs)
This method requires all the config parms specified by the ExampleFileFilter.
parent
- the owner of this dialog (generally just send this)startPath
- the dir to start the file chooser dialog fromfilters
- an array holding the Filters to use in the dialogfilesAndDirs
- specs if the user will be allowed to choose both
files or dirs.public static String chooseAFilename(Component parent, String startPath, ExampleFileFilter[] filters, boolean filesAndDirs, short openOrClose)
This method requires all the config parms specified by the ExampleFileFilter.
parent
- the owner of this dialog (generally just send this)startPath
- the dir to start the file chooser dialog fromfilters
- an array holding the Filters to use in the dialogfilesAndDirs
- specs if the user will be allowed to choose both
files or dirs.openOrClose
- Description of the Parameterpublic static String absoluteToPwdRelativePath(File absPath)
absPath
- is the File to use to to convertpublic static String absoluteToPwdRelativePath(String absPath)
absPath
- is the absolute path to convertpublic static String removeParentRelativeReference(String path)
path
- is the absolute path to convertpublic static File getFileDir(String fileString)
fileString
- is the filename to get the dir forpublic static String getFileDirStr(String fileString)
fileString
- is the filename to get the dir forpublic static URL getFileBaseURL(String fileString)
fileString
- is the filename to turn into a file://URLpublic static URL[] getFileBaseURLs(String[] fileStrings)
fileStrings
- Description of Parameterpublic static String encodeToURL(String s)
The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.
The unreserved characters - _ . ! ~ * ' ( ) remain the same.
The space character ' ' is converted into a plus sign '+'.
All other ASCII characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the character code
All non-ASCII characters are encoded in two steps: first to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; secondly each of these bytes is encoded as "%xx".
s
- The string to be encodedpublic static InetAddress getLocalhostName()
public static double sphereDistanceBetween(double lat1, double lng1, double lat2, double lng2)
public static String executeNativeApp(String executableLocation, String[] cmds, boolean verboseOutput)
executableLocation
- is the path to the executable to runcmds
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.verboseOutput
- flag for optionaly printing extra application state output.StreamGobbler
,
Runtime.getRuntime()
public static String executeNativeApp(String executableLocation, String[] cmds, boolean verboseOutput, String workingDir)
executableLocation
- is the path to the executable to runcmds
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.verboseOutput
- flag for optionaly printing extra application state output.workingDir
- the working dir to exec from - To inherit current, pass a null.StreamGobbler
,
Runtime.getRuntime()
public static int executeNativeApp(String executableLocation, String[] cmds, String outFilename, boolean verboseOutput)
executableLocation
- is the path to the executable to runcmds
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.outFilename
- an outputFile to dump the exe output (If this is null
it sends the output to System.out).verboseOutput
- flag for optionaly printing extra applicvation state output.StreamGobbler
,
Runtime.getRuntime()
public static int executeNativeApp(String executableLocation, Vector appParms, String outFilename, StreamGobbler inputGobbler, boolean verboseOutput)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.outFilename
- an outputFile to dump the exe output (If this is null
it sends the output to System.out).inputGobbler
- is the StreamGobbler object to use in gobbling the Commands InputStream.verboseOutput
- flag for optionaly printing extra applicvation state output.StreamGobbler
,
Runtime.getRuntime()
public static int executeNativeApp(String executableLocation, Vector appParms, String outFilename, StreamGobbler inputGobbler, boolean verboseOutput, String workingDir)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.outFilename
- an outputFile to dump the exe output (If this is null
it sends the output to System.out).inputGobbler
- is the StreamGobbler object to use in gobbling the Commands InputStream.verboseOutput
- flag for optionaly printing extra applicvation state output.workingDir
- the working dir to exec from - To inherit current, pass a null.StreamGobbler
,
Runtime.getRuntime()
public static int executeNativeApp(String executableLocation, String[] cmds, String outFilename, StreamGobbler inputGobbler, boolean verboseOutput, String workingDir)
executableLocation
- is the path to the executable to runcmds
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.outFilename
- an outputFile to dump the exe output (If this is null
it sends the output to System.out).inputGobbler
- is the StreamGobbler object to use in gobbling the Commands InputStream.verboseOutput
- flag for optionaly printing extra applicvation state output.workingDir
- the working dir to exec from - To inherit current, pass a null.StreamGobbler
,
Runtime.getRuntime()
public static boolean threadWatchdog(Thread watchThread, long timeToTerminate) throws SecurityException
watchThread
- is the thread to watchtimeToTerminate
- is the time to wait befor InteruptingSecurityException
- If the interrupt is not allowed on the threadpublic static int executeNativeApp(String executableLocation, Vector appParms, String outFilename)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.outFilename
- an outputFile to dump the exe output.StreamGobbler
,
Runtime.getRuntime()
public static int executeNativeApp(String executableLocation, Vector appParms, String outFilename, boolean verboseOutput)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.outFilename
- an outputFile to dump the exe output (This can be null)verboseOutput
- flag for optionaly printing extra applicvation state output.StreamGobbler
,
Runtime.getRuntime()
public static String executeNativeApp(String executableLocation, Vector appParms, boolean verboseOutput)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.verboseOutput
- flag for optionaly printing extra applicvation state output.StreamGobbler
,
Runtime.getRuntime()
public static String executeNativeApp(String executableLocation, Vector appParms, boolean verboseOutput, String workingDir)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the
end of the commandline that gets executed.verboseOutput
- flag for optionaly printing extra applicvation state output.StreamGobbler
,
Runtime.getRuntime()
public static Date getCurrentDate()
public static long countFilesInDir(String dirName, boolean recurse)
dirName
- recurse
- WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses