public class JTFTools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
checkIfLoaded(java.lang.String className)
Returns true if the specified class is already loaded.
|
static void |
copyBytes(java.io.InputStream in,
java.io.OutputStream out,
long nBytes)
Copies the specified number bytes from the input stream to the output stream.
|
static void |
copyFile(java.io.File oldFile,
java.io.File newFile)
Copies a file from
oldFile to newFile . |
static java.awt.Container |
createEmptyContainer()
Returns an empty lightweight container.
|
static java.awt.Color |
decodeColor(java.lang.String name)
Decodes a color name.
|
static java.awt.Font |
decodeFont(java.lang.String str)
Decodes a font in the style of
Font.decode . |
static java.awt.Font |
decodeFont(java.lang.String str,
java.awt.Font oldFont)
Decodes a font in the style of
Font.decode . |
static java.lang.String |
findFontFamily(java.lang.String str)
Finds the first font family in the string
str that exists in the
current GraphicsEnvironment . |
static java.lang.String |
getCommandLine()
Returns the command line that invoked this program, or
null if
no command line is available. |
static java.awt.Frame |
getEnclosingFrame(java.awt.Component comp)
Returns the frame that encloses the specified component.
|
static java.lang.String[] |
getFontList()
Returns an array of the available font family names.
|
static java.lang.String |
getLocalHostName()
Returns the canonical name of the local host.
|
static java.lang.String |
getMainClass()
Returns the name of the main class.
|
static java.awt.Font |
getStandardFont(java.awt.Font font)
Returns a font that will approximate the specified font in this environment.
|
static boolean |
isAnonymous(java.lang.Thread t)
Returns
true if the supplied thread is an anonymous one created
automatically by the system. |
static boolean |
matchFilenamePattern(java.lang.String filename,
java.lang.String pattern)
Determines whether the filename matches the specified pattern.
|
static java.io.OutputStream |
openBase64OutputStream(java.io.PrintStream printStream)
Opens an output stream that allows the client to write data using Base64
encoding, which is the most common encoding for mail attachments.
|
static java.io.OutputStream |
openHexByteOutputStream(java.io.PrintStream printStream)
Opens an output stream that allows the client to write data using pairs of
hex characters.
|
static void |
padBase64OutputStream(java.io.OutputStream out)
Pads the data in the specified output stream without closing it.
|
static void |
pause(double milliseconds)
Delays the calling thread for the specified time, which is expressed in
milliseconds.
|
static void |
setDebugOptions(java.lang.String options)
Sets the debugging options in place for this run.
|
static boolean |
testDebugOption(java.lang.String option)
Tests to see whether the current program was invoked with a
debug parameter that contains the specified string as a lexical
unit in a string delimited by + signs. |
public static void pause(double milliseconds)
Thread.sleep
, this method never throws an
exception.milliseconds
- The sleep time in millisecondspublic static java.awt.Container createEmptyContainer()
public static java.awt.Frame getEnclosingFrame(java.awt.Component comp)
comp
- The component at which to start the searchFrame
objectpublic static java.awt.Font getStandardFont(java.awt.Font font)
Serif
, SansSerif
, and
Monospaced
.font
- The font being checkedpublic static java.lang.String[] getFontList()
public static java.lang.String findFontFamily(java.lang.String str)
str
that exists in the
current GraphicsEnvironment
. As in HTML font tags, the
str
consists of a set of font names separated by semicolons. The
findFontFamily
method returns the first family name that exists
in the list of loaded fonts, or null
if there are none.str
- The list of family names separated by semicolonsnull
if nonepublic static java.awt.Font decodeFont(java.lang.String str)
Font.decode
.str
- The string to decodepublic static java.awt.Font decodeFont(java.lang.String str, java.awt.Font oldFont)
Font.decode
. The only difference
is that this method takes a font parameter that gives default values for the
different parts of the font. If the family, size, or style is specified as an
asterisk, the corresponding value is taken from the supplied font.str
- The string to decodeoldFont
- The font whose properties are used as defaultspublic static java.awt.Color decodeColor(java.lang.String name)
Color.decode
except in that it allows named colors and system colors.name
- The string name of the colorpublic static boolean matchFilenamePattern(java.lang.String filename, java.lang.String pattern)
? |
Matches any single character |
* |
Matches any sequence of characters |
[...] |
Matches any of the specified characters |
[^...] |
Matches any character except the specified ones |
a-z
.filename
- The filename being testedpattern
- The pattern including wildcardstrue
if the filename matches the patternpublic static void setDebugOptions(java.lang.String options)
+
sign character.options
- The names of the enabled options separated by plus signspublic static boolean testDebugOption(java.lang.String option)
debug
parameter that contains the specified string as a lexical
unit in a string delimited by +
signs.option
- The name of the optiontrue
if the specified debug option is in
effectpublic static java.lang.String getCommandLine()
null
if
no command line is available.public static java.lang.String getMainClass()
public static boolean checkIfLoaded(java.lang.String className)
className
- The name of the classpublic static boolean isAnonymous(java.lang.Thread t)
true
if the supplied thread is an anonymous one created
automatically by the system.t
- The thread being testedpublic static java.io.OutputStream openHexByteOutputStream(java.io.PrintStream printStream)
OutputStream
that the
client can use to which the client can send binary data, which is then
written in encoded form to the underlying PrintStream
object.printStream
- The underlying PrintStream
to which data is
writtenOutputStream
for writing binary datapublic static java.io.OutputStream openBase64OutputStream(java.io.PrintStream printStream)
OutputStream
that the client can use to which the
client can send binary data, which is then written in encoded form to the
underlying PrintStream
object. Closing the stream automatically
pads the data to complete a Base64 unit. To pad the data without closing the
stream (as one would need to do for a multi-attachment message, for example),
call the padBase64OutputStream
method.printStream
- The underlying PrintStream
to which data is
writtenOutputStream
for writing binary datapublic static void padBase64OutputStream(java.io.OutputStream out)
PrintStream
.out
- The output stream returned by openBase64OutputStream
public static java.lang.String getLocalHostName()
null
if
unavailablepublic static void copyFile(java.io.File oldFile, java.io.File newFile)
oldFile
to newFile
.oldFile
- A File
object indicating the existing filenewFile
- A File
object indicating the new filepublic static void copyBytes(java.io.InputStream in, java.io.OutputStream out, long nBytes) throws java.io.IOException
in
- The input streamout
- The output streamnBytes
- The number of bytes to copyjava.io.IOException