public final class Util extends Object
Modifier and Type | Method and Description |
---|---|
static void |
belowWithin(Component parent,
Component child) |
static Point |
belowWithin(Rectangle rec,
Dimension dim) |
static void |
centreWithin(Component parent,
Component child)
Centres the child component within its parent.
|
static Point |
centreWithin(Rectangle rec,
Dimension dim)
Calculates the X and Y coordinates that a child component should have to be centered
within its parent.
|
static void |
copyFile(File inputFile,
File outputFile)
Copies the contents of any disk file to a specified output file.
|
static boolean |
deleteDir(File dir)
Deletes all files and subdirectories under dir.
|
static boolean |
ensureDirectory(File dir,
File defaultDir)
Ensures the existence of the directory specified by the parameter.
|
static boolean |
ensureFilePath(File file,
File defaultDir)
Ensures the existence of the directory which may be part of the path
specification of parameter
file . |
static String |
fileNameOfPath(String path) |
static String |
htmlEncoded(String text)
Substitutes conflicting characters in
text with html
masked expressions. |
static String |
pathNameOfPath(String path) |
static void |
rightWithin(Component parent,
Component child)
Puts to the right
|
static Point |
rightWithin(Rectangle rec,
Dimension dim) |
static String |
substituteText(String text,
String token,
String substitute)
Renders a string based on
text where any occurence of
token is replaced by substitute . |
static String |
substituteTextS(String text,
String token,
String substitute)
Renders a string based on
text where any occurence of
token is replaced by substitute . |
static int |
textVariance(char[] ca) |
public static Point centreWithin(Rectangle rec, Dimension dim)
rec
- the bounding rectangle of the parent.dim
- the dimensions of the child.public static void centreWithin(Component parent, Component child)
parent
- the parent component.child
- the child component.public static void rightWithin(Component parent, Component child)
parent
- the parent component.child
- the child component.public static String substituteText(String text, String token, String substitute)
text
where any occurence of
token
is replaced by substitute
.public static String substituteTextS(String text, String token, String substitute)
text
where any occurence of
token
is replaced by substitute
.public static String htmlEncoded(String text)
text
with html
masked expressions. The returned string is displayable in html interpreting
components.text
- public static void copyFile(File inputFile, File outputFile) throws IOException
StreamCorruptedException
is thrown.
Function reports errors to System.err
.inputFile
- a File objectoutputFile
- a File objectIOException
- if the function could not be completed
because of an IO or CRC check errorpublic static boolean ensureFilePath(File file, File defaultDir)
file
. If the specified file is a
relative path, it is made absolute against defaultDir
. If
defaultDir
is null the System property "user.dir" is
assumed as default directory.public static boolean ensureDirectory(File dir, File defaultDir)
dir
- File specifying the intended directory; if the specified
path is a relative path, it is made absolute against defaultDir
.
If defaultDir
is null the System directory "user.dir" is
assumed as default.public static int textVariance(char[] ca)
public static boolean deleteDir(File dir)
Jas4pp 1.5 © Java Analysis Studio for Particle Physics