| java.lang.Object com.quadcap.util.Util
Util | public class Util (Code) | | This class aggregates a bunch of various string manipulation utilities.
author: Stan Bailes |
Method Summary | |
public static boolean | boolProperty(String s) | public static byte[] | bytes(String s) | public static byte[] | bytes(int i) | public static byte[] | bytes(long i) Convert a long to a byte array, MSB first. | public static void | bytesToChars(byte[] bbuf, int boff, char[] cbuf, int coff, int clen) | final public static long | bytesToLong(byte[] buf) Convert a byte array which represents a long into a long.
Parameters: buf - the byte array, MSB first. | final public static long | bytesToLong(byte[] buf, int offset) Convert a byte array which represents a long into a long.
Parameters: buf - the byte array, MSB first. | public static void | charsToBytes(char[] cbuf, int coff, byte[] bbuf, int boff, int clen) | public static Object | checkCapacity(Object array, int desiredcap) | public static int | compareBytes(byte[] k1, int s1, int c1, byte[] k2, int s2, int c2) Byte-array comparison. | public static int | compareBytes(byte[] b1, byte[] b2) | public static int | compareObjects(Object a, Object b) | public static void | copyStream(InputStream in, OutputStream out) | public static int | execCommand(String cmd, OutputStream out, OutputStream err) | public static int | execCommand(String[] cmdarray, OutputStream out, OutputStream err) | public static int | execCommand(String cmd, OutputStream out) | public static String | execCommand(String cmd) | public static String | execCommand(String[] cmd) | public static String | execCommand(String a, String b) | public static String | execCommand(String a, String b, String c) | public static String | getStackTrace(Throwable t) | public static String | hexBytes(byte[] buf) | public static String | hexBytes(byte[] buf, int off, int len) | public static String | hexInts(byte[] buf) | public static String | hexInts(byte[] buf, int off, int len) | public static String | htmlEscape(String s) | public static int | intProperty(String s, int defVal) | public static int | integer(byte[] buf) Convert a byte array which represents an integer into an integer.
Parameters: buf - the byte array, MSB first. | public static int | integer(byte[] buf, int pos) Extract an integer from four bytes in a byte array. | final public static void | join(Thread t) Utility to join without having to worry about catching
InterruptedException. | public static String[] | listFiles(File f) | public static Thread | makeCopyThread(InputStream in, OutputStream out) Create a thread which copies bytes from an input stream to
an output stream until end of file is reached. | public static Hashtable | parseArgs(String args) | public static List | parseIntList(String s) Parse a comma-separated list of integers or integer ranges. | final public static Properties | parsePropsString(String extraProps) | public static void | putInt(byte[] buf, int pos, int val) | public static void | putLong(byte[] buf, int pos, long val) | public static String | readFile(String filename) | final public static void | sleep(long ms) Utility to sleep without having to worry about catching
InterruptedException. | public static Vector | split(String s, char delim) Split a string into a vector of elements. | public static Vector | split(String s, char delim, int cnt) | public static String | stackTrace() Return a string showing the current stack trace. | public static String | stackTrace(boolean condense) | public static String | stackTrace(Throwable e, boolean condense) Return a string showing the current stack trace. | public static String | strBytes(byte[] buf, int offset, int len) | public static String | strBytes(byte[] buf) | public static byte[] | strCharsAsBytes(String s) | public static String | strProperty(String s, String defVal) | public static File | userFile(String name) Return a File object corresponding to the specified file name.
If the name is relative, it is located relative to the user's
current directory. | public static int | waitFor(Process p, OutputStream out, OutputStream err) | final public static int | waitFor(Process p) |
hexMap | public static char[] hexMap(Code) | | |
lastTrace | static int lastTrace(Code) | | |
boolProperty | public static boolean boolProperty(String s)(Code) | | |
bytes | public static byte[] bytes(int i)(Code) | | Convert an int to a byte array, MSB first
Parameters: i - the int value |
bytes | public static byte[] bytes(long i)(Code) | | Convert a long to a byte array, MSB first.
Parameters: i - the long value |
bytesToChars | public static void bytesToChars(byte[] bbuf, int boff, char[] cbuf, int coff, int clen)(Code) | | |
bytesToLong | final public static long bytesToLong(byte[] buf)(Code) | | Convert a byte array which represents a long into a long.
Parameters: buf - the byte array, MSB first. the long value stored in the byte array. |
bytesToLong | final public static long bytesToLong(byte[] buf, int offset)(Code) | | Convert a byte array which represents a long into a long.
Parameters: buf - the byte array, MSB first. the long value stored in the byte array. |
charsToBytes | public static void charsToBytes(char[] cbuf, int coff, byte[] bbuf, int boff, int clen)(Code) | | |
checkCapacity | public static Object checkCapacity(Object array, int desiredcap)(Code) | | Generic array resizer
|
compareBytes | public static int compareBytes(byte[] k1, int s1, int c1, byte[] k2, int s2, int c2)(Code) | | Byte-array comparison.
Parameters: k1 - the byte array containing key 1. Parameters: s1 - the starting offset of key 1 in k1 . Parameters: c1 - the length of key 1. Parameters: k2 - the byte array containing key 2. Parameters: s2 - the starting offset of key 2 in k2 . Parameters: c2 - the length of key 2.< zero | if key1 is less than key2 | zero | if key1 is equal to key2 | > zero | if key1 is greater than key2 |
|
compareBytes | public static int compareBytes(byte[] b1, byte[] b2)(Code) | | |
hexBytes | public static String hexBytes(byte[] buf, int off, int len)(Code) | | |
hexInts | public static String hexInts(byte[] buf, int off, int len)(Code) | | |
intProperty | public static int intProperty(String s, int defVal)(Code) | | |
integer | public static int integer(byte[] buf)(Code) | | Convert a byte array which represents an integer into an integer.
Parameters: buf - the byte array, MSB first. the integer value stored in the byte array. |
integer | public static int integer(byte[] buf, int pos)(Code) | | Extract an integer from four bytes in a byte array.
Parameters: buf - the byte array Parameters: pos - the offset in the array of the first (MSB) byte of the int the integer value stored in the byte array. |
join | final public static void join(Thread t)(Code) | | Utility to join without having to worry about catching
InterruptedException.
Parameters: t - the thread to wait for |
listFiles | public static String[] listFiles(File f)(Code) | | Like File.list(), but returns directories first, and sorts alpha
|
makeCopyThread | public static Thread makeCopyThread(InputStream in, OutputStream out)(Code) | | Create a thread which copies bytes from an input stream to
an output stream until end of file is reached.
|
parseIntList | public static List parseIntList(String s)(Code) | | Parse a comma-separated list of integers or integer ranges.
Example: 1,2
Example: 1,3-5,77
a List of Integers |
parsePropsString | final public static Properties parsePropsString(String extraProps)(Code) | | Parse a semicolon-separated property list:
prop1=val1;prop2=val2
|
putInt | public static void putInt(byte[] buf, int pos, int val)(Code) | | |
putLong | public static void putLong(byte[] buf, int pos, long val)(Code) | | |
sleep | final public static void sleep(long ms)(Code) | | Utility to sleep without having to worry about catching
InterruptedException.
Parameters: ms - milliseconds to sleep. |
split | public static Vector split(String s, char delim)(Code) | | Split a string into a vector of elements.
|
stackTrace | public static String stackTrace()(Code) | | Return a string showing the current stack trace.
|
stackTrace | public static String stackTrace(boolean condense)(Code) | | |
stackTrace | public static String stackTrace(Throwable e, boolean condense)(Code) | | Return a string showing the current stack trace.
|
strBytes | public static String strBytes(byte[] buf, int offset, int len)(Code) | | |
strCharsAsBytes | public static byte[] strCharsAsBytes(String s)(Code) | | To hell with character encodings ;-)
|
userFile | public static File userFile(String name)(Code) | | Return a File object corresponding to the specified file name.
If the name is relative, it is located relative to the user's
current directory. This is helpful for the case when we run
as a service from the /winnt/system32 directory and want to
open files relative to our install root.
Parameters: name - the file name the file |
waitFor | final public static int waitFor(Process p)(Code) | | Utility to wait for a process without having to worry about catching
InterruptedException
Parameters: p - the process to wait for |
|
|