public class SystemUtilities extends Object
| Constructor and Description |
|---|
SystemUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static String |
buildPathToRunningVM()
This is done to insure that the VM executed is the same as the currently running
one.
|
static String |
changeFileExt(String sFileName,
String sExt)
change file extension
|
static String |
changeFileName(String sFileName,
String sPrefix,
String sSuffix,
String sExt)
change file name + extension
retain file directory
|
static File[] |
directoryList(File dir)
get the list of directories in the directory (recursive)
|
static File[] |
driveList()
list all drives/filesystem roots on my system?
|
static String |
extractDirectory(String strFile)
Returns the name of the file or directory denoted by this abstract
pathname.
|
static String |
extractFileDirectory(String sPath)
extract the file directory e.g.
1. orange.svg -> EMPTY
2. http://server/directory/apple.svg -> http://server/directory/
3. file:\\c:\durian.svg -> file:\\c:\
|
static String |
extractFileName(String sFileName)
extract filename without directory information e.g.
1. orange.svg -> orange.svg
2. http://server/directory/apple.svg -> apple.svg
3. file:\\c:\durian.svg -> durian.svg
|
static String |
extractFileNameFromURL(String strFile)
Returns the name of the file or directory denoted by this abstract
pathname.
|
static String |
extractFileNameOnly(String sFileName)
extract filename without file extension and directory information e.g.
1. orange.svg -> orange
2. http://server/directory/apple.svg -> apple
3. file:\\c:\durian.svg -> durian
|
static String |
extractHostDir(String sURL)
extract the directory from URL or FTP address
1. http://serverAAA/directory/apple.svg -> directory/
2. http://serverAAA/directory/123/apple.svg -> directory/123/
|
static boolean |
fileCanZip(String name)
determine whether type of file can be zipped based on file extension
|
static boolean |
filecopy(File from,
File to)
file copy
|
static boolean |
filecopy(String sFrom,
String sTo)
file copy (Filenames)
|
static boolean |
filecopy(String sFrom,
String sTo,
int offset,
int len)
file copy (Filenames)
|
static byte[] |
fileRead(String filename)
read byte array data from source file
|
static long |
fileSize(String filename)
get file size
|
static boolean |
fileWrite(String filename,
String data)
write byte array data to a file
|
static String |
getContentTypeFromName(String filename)
generate the MIME type for a specified filename based on file extension
|
static String |
getDateTime()
get date time in a useful string
e.g. date=15 Jan 2003, time=15:40:12
returns 20030115154012 + timezone
|
static String |
getDateTime14()
get date time in a 14-character string
e.g. date=15 Jan 2003, time=15:40:12
returns 20030115154012 + timezone
|
static String |
getDateTime8()
get date time in a 8-character string
e.g. date=15 Jan 2003
returns 20030115
|
static String[] |
getFiles(String sDir,
String sExt)
get list of files from a directory
|
static int[] |
getPixels(Image parImage,
int parWidth,
int parHeight)
get array of pixels, invoked by loadBitmap
|
static int |
HexToInt(String s)
convert hex to int
|
static String |
ipHashToStr(int iHashcode)
convert a hash value into a 4 dotted decimal
|
static Image |
loadBitmap(String sfile)
loading bitmaps
Modified
"Java Tip 43: How to read 8- and 24-bit Microsoft Windows bitmaps in Java applications"
Also see "List of Java libraries to read and write image files"
http://www.geocities.com/marcoschmidt.geo/java-image-coding.html
|
static String |
pad(int size,
String symbol)
pad - create a padded string with symbol
(adapted from Chapter 6 of Introduction to OOP by Thomas Otani)
|
static Color |
parseHtmlColor(String s)
Convert HTML color value (format "#RRGGBB"
where RR, GG, and BB are hexadecimal values) to Java Color object.
|
static String |
propertyLoad(String filename,
String entry,
String default_value)
read an entry value from a property/INI file
e.g.
|
static boolean |
propertyStore(String filename,
String header,
String entry,
String value)
save an entry value from a property/INI file
e.g.
|
static boolean |
screenCapture(String sFileName)
perform screen capture (entire screen, part of a screen using
rectangle/dimension)
|
static boolean |
screenCapture(String sFileName,
Component c)
This utility method does the actual screencapture of the OpenMap and 2D
Mission views
|
static boolean |
screenCapture(String sFileName,
Dimension scrDimen)
perform screen capture (entire screen, part of a screen using
rectangle/dimension)
|
static boolean |
screenCapture(String sFileName,
int scrX,
int scrY,
int scrWidth,
int scrHeight)
perform screen capture (entire screen, part of a screen using
rectangle/dimension)
|
static boolean |
screenCapture(String sFileName,
Rectangle scrRect)
perform screen capture (entire screen, part of a screen using
rectangle/dimension)
|
static boolean |
screenCapture(String sFileName,
Rectangle scrRect,
String typ) |
static boolean |
screenCapture(String sFileName,
String typ) |
static void |
sysOutPrint(char c) |
static void |
sysOutPrint(String s) |
static void |
sysOutPrintln(String s)
Provide synchronized methods for multiple threads to use single run-time messages panel.
|
public static String buildPathToRunningVM()
public static File[] driveList()
public static File[] directoryList(File dir)
dir - to searchpublic static String extractDirectory(String strFile)
strFile - URLpublic static String extractFileNameFromURL(String strFile)
strFile - URLpublic static String extractFileName(String sFileName)
sFileName - filenamepublic static String extractFileNameOnly(String sFileName)
sFileName - filenamepublic static String extractFileDirectory(String sPath)
sPath - file pathpublic static String extractHostDir(String sURL)
sURL - file pathpublic static String changeFileExt(String sFileName, String sExt)
sFileName - filenamesExt - file extension to be changedpublic static String changeFileName(String sFileName, String sPrefix, String sSuffix, String sExt)
sFileName - filenamesPrefix - prefix to be appendedsSuffix - prefix to be appendedsExt - file extension to be changed topublic static boolean fileCanZip(String name)
name - filenamepublic static boolean filecopy(File from, File to)
from - source fileto - destination filepublic static boolean filecopy(String sFrom, String sTo) throws IOException
sFrom - input filenamesTo - output filenameIOException - failurepublic static boolean filecopy(String sFrom, String sTo, int offset, int len) throws IOException
sFrom - source filesTo - destination fileoffset - offsetlen - lengthIOException - failurepublic static byte[] fileRead(String filename) throws IOException
filename - source file to be read fromIOException - IO exception errorpublic static long fileSize(String filename)
filename - file namepublic static boolean fileWrite(String filename, String data) throws IOException
filename - destination filedata - write byte array data to fileIOException - IO exception errorpublic static String getDateTime14()
public static String getDateTime()
public static String getDateTime8()
public static String[] getFiles(String sDir, String sExt)
sDir - directory namesExt - file extension filter (case insensitive)public static String getContentTypeFromName(String filename)
filename - name of filepublic static String ipHashToStr(int iHashcode)
iHashcode - IP address as Integerpublic static Image loadBitmap(String sfile)
sfile - bitmap file to be loadedpublic static int[] getPixels(Image parImage, int parWidth, int parHeight)
parImage - imageparWidth - width of imageparHeight - height of imagepublic static Color parseHtmlColor(String s)
s - HTML hex string valuepublic static int HexToInt(String s)
s - hex stringpublic static String pad(int size, String symbol)
size - size of paddingsymbol - symbol to be padded withpublic static String propertyLoad(String filename, String entry, String default_value)
filename - property/INI fileentry - entry to be readdefault_value - default value if no entry foundpublic static boolean propertyStore(String filename, String header, String entry, String value)
filename - property/INI fileheader - comments at the top of the property fileentry - entry to be storedvalue - value to be storedpublic static boolean screenCapture(String sFileName)
sFileName - location to store screen capturepublic static boolean screenCapture(String sFileName, Dimension scrDimen)
sFileName - location to store screen capturescrDimen - screen capture size defined as Dimensionpublic static boolean screenCapture(String sFileName, int scrX, int scrY, int scrWidth, int scrHeight)
sFileName - location to store screen capturescrX - location XscrY - location YscrWidth - widthscrHeight - heightpublic static boolean screenCapture(String sFileName, Rectangle scrRect)
sFileName - location to store screen capturescrRect - screen capture size defined as Rectanglepublic static boolean screenCapture(String sFileName, Component c)
sFileName - the name of the PNG file to write the image toc - the component to paint for the image capturepublic static void sysOutPrintln(String s)
s - public static void sysOutPrint(String s)
public static void sysOutPrint(char c)