|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--kom.tools.util.Util
Some helpful utilities
Constructor Summary | |
Util()
|
Method Summary | |
static boolean |
copyFile(java.io.File from,
java.io.File to)
Copies a file from one location to another |
static boolean |
copyFile(java.lang.String from,
java.lang.String to)
Copies a file from one location to another |
static java.lang.String |
currTime()
Creates a string representing current time |
static boolean |
equal(java.lang.String s1,
java.lang.String s2)
Compares strings, null-safe |
static int |
getInt(java.lang.String value)
Gets the value of a string in Integer format |
static int |
getInt(java.lang.String value,
int defval)
Gets the value of a string in Integer format |
static long |
getLong(java.lang.String value,
long defval)
Gets the Long value of the input string |
static boolean |
isNullOrEmpty(java.lang.String str)
Tests for null or empty string |
static void |
purgeAllFiles(java.lang.String dir)
Removes all files from a directory |
static void |
purgeFilesWithPrefix(java.lang.String dir,
java.lang.String pre)
Removes all files with a specific prefix from a directory. |
static java.lang.String |
rand()
Generates a random number in String format |
static java.lang.String |
readLine(java.io.InputStream stream)
Reads a line from an input stream |
static java.lang.String |
secTime(java.util.Date date)
Creates a string representing time |
static java.lang.String[] |
string2array(java.lang.String v,
java.lang.String d)
Splits a String at delimiters into a String[] array. |
static java.lang.String |
toFile(java.lang.String name)
"Sanitizes" a file name |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public Util()
Method Detail |
public static boolean isNullOrEmpty(java.lang.String str)
str
- The input stringpublic static final boolean equal(java.lang.String s1, java.lang.String s2)
s1
- First Strings2
- Second Stringpublic static final int getInt(java.lang.String value)
value
- The string (should be an Integer encoding of a number >= 0)public static final int getInt(java.lang.String value, int defval)
value
- The string (should be an Integer encoding of a number >= 0)defval
- Default value if string could not be parsedpublic static final long getLong(java.lang.String value, long defval)
value
- The input string (should be a number >=0)defval
- Default value if string could not be parsedpublic static java.lang.String readLine(java.io.InputStream stream)
stream
- The input streampublic static boolean copyFile(java.lang.String from, java.lang.String to)
from
- The source file pathto
- The destination pathpublic static boolean copyFile(java.io.File from, java.io.File to)
from
- The source Fileto
- The destination Filepublic static void purgeAllFiles(java.lang.String dir)
dir
- The directory name + any directory separatorpublic static void purgeFilesWithPrefix(java.lang.String dir, java.lang.String pre)
dir
- The directory (including any directory separator)pre
- The prefix for the file namepublic static java.lang.String toFile(java.lang.String name)
name
- The tentative file namepublic static java.lang.String rand()
public static java.lang.String currTime()
public static java.lang.String secTime(java.util.Date date)
date
- Date valuepublic static java.lang.String[] string2array(java.lang.String v, java.lang.String d)
v
- String. Example: "a,b,c" will be converted to
String[] = {"a", "b", "c"} if d == ",".d
- String of delimiter characters
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |