Utility class.
Type Params | Return Type | Name and description |
---|---|---|
|
static String |
bytesToHexDump(byte[] data, int ofs, int len) Convert a byte array into a formatted hex dump. |
|
static String |
bytesToHexDump(byte[] data) Convert a byte array into a formatted hex dump. |
|
static String |
bytesToHexString(byte[] data) Convert from a byte array into a hexadecimal string. |
|
static void |
closeQuietly(InputStream is) close input stream quietly. |
|
static void |
closeQuietly(OutputStream os) close output stream quietly. |
|
static void |
closeQuietly(Socket sock) close socket quietly. |
|
static void |
closeQuietly(DatagramSocket sock) close multicast socket quietly. |
|
static String |
formatMessage(Message msg, Object... args) Convenience method for pretty printing of messages. |
|
static byte[] |
gunzip(byte[] data) Uncompress byte array. |
|
static byte[] |
gzip(byte[] data) Compress byte array. |
|
static byte[] |
hexStringToBytes(String s) Convert from a hexadecimal string to a byte array. |
|
static String |
locationToString(double[] location) Convert location array into a printable string. |
|
static Float |
round(Float x, int n) Round off to n decimal places. |
|
static Float |
round(Double x, int n) Round off to n decimal places. |
|
static String |
typeToString(int type) Convert frame type into a printable string. |
Convert a byte array into a formatted hex dump.
data
- byte arrayofs
- start offset for dumplen
- number of bytes to dumpConvert a byte array into a formatted hex dump.
data
- byte arrayConvert from a byte array into a hexadecimal string.
data
- byte arrayclose input stream quietly.
is
- InputStreamclose output stream quietly.
os
- OutputStreamclose multicast socket quietly.
sock
- SocketConvenience method for pretty printing of messages. args are printed with spaces between them. Null or NaN arguments are ignored. If an arg ends with a ":", it is interpreted as a keyword associated with the following argument, and is only printed if the next argument is non-null. If an arg begins with a ":", it is interpreted as a suffix associated with the following argument, and is only printed if the next argument is non-null. Additionally, if the suffix ends with a "s?" and the agument is integer, the "s" is dropped if the argument is 1, and included if it is not. The "?" is dropped. This is useful to print singlular/plural counts.
msg
- message to printargs
- details of message to printUncompress byte array.
data
- data to uncompressCompress byte array.
data
- data to compressConvert from a hexadecimal string to a byte array.
s
- hexadecimal representation of the dataConvert location array into a printable string.
location
- array with location informationRound off to n decimal places.
x
- value to round offn
- number of decimal places to round toRound off to n decimal places.
x
- value to round offn
- number of decimal places to round toConvert frame type into a printable string.
type
- frame type