public final class DebugUtils
extends Object
DebugUtils: Debugging utilties.
| Constructor | Description |
|---|---|
DebugUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static java.io.File |
byteArrayToFile(byte[] data,
String filePath) |
Dump a buffer of bytes to a file.
|
static boolean |
doesStackContainMethod(String methodName) |
Examine current stack trace to determine if the specified method name in the the trace.
|
static String |
formatBytes(byte[] data) |
Format byte array for printing.
|
static String |
formatBytes(byte[] data,
boolean showIndex) |
Format byte array for printing.
|
static String |
formatBytes(byte[] data,
int offset,
int len) |
Format byte array for printing.
|
static String |
formatBytes(byte[] data,
int offset,
int len,
boolean showIndex) |
Format byte array for printing.
|
static String |
formatBytesInSingleRow(byte[] data,
int offset,
int len) |
Format byte array for printing.
|
static String |
formatBytesShort(byte[] data) |
Format byte array for printing.
|
static String |
formatBytesShort(byte[] data,
int offset,
int len) |
Format byte array for printing.
|
static String |
formatBytesStruct(byte[] data) |
|
static String |
formatBytesStruct(byte[] data,
int offset,
int len) |
Format byte array for printing.
|
static String |
formatMilliseconds(long ms) |
Give a time in seconds, return a String representing the time in hh:mm:ss.mmm.
|
static String |
formatSeconds(long t) |
Give a time in seconds, return a String representing the time in hh:mm:ss.
|
static String |
formatUtcTime(long utcTime) |
|
static String |
stackTraceToSingleLineString(Throwable e,
int maxLines) |
Given an exception, return single line String representation.
|
static String |
stackTraceToString(Throwable e) |
Given an exception, return String representation.
|
static String |
stackTraceToString(Throwable e,
int maxLines,
String seperator) |
Given an exception, return single line String representation.
|
static String |
toHex(byte value) |
Format a byte value to a 0xff format
|
static String |
toHex(int value) |
Format a byte value to a 0xffffffff format
|
static String |
toLong(long value) |
Format a long value to a 0xffffffffffffffff format
|
public static java.io.File byteArrayToFile(byte[] data,
String filePath)
data - a buffer of bytesfilePath - The path and filenamepublic static boolean doesStackContainMethod(String methodName)
Could be enhanced quite a bit by also checking for Class and method. But simple for now.
methodName - public static String formatBytes(byte[] data)
data - byte arraypublic static String formatBytes(byte[] data,
boolean showIndex)
data - byte arraypublic static String formatBytes(byte[] data,
int offset,
int len)
data - byte arrayoffset - start index in arraylen - length to formatpublic static String formatBytes(byte[] data,
int offset,
int len,
boolean showIndex)
data - byte arrayoffset - start index in arraylen - length to formatpublic static String formatBytesInSingleRow(byte[] data,
int offset,
int len)
data - byte arrayoffset - start index in arraylen - length to formatpublic static String formatBytesShort(byte[] data)
data - byte arraypublic static String formatBytesShort(byte[] data,
int offset,
int len)
data - byte arrayoffset - offset in arraylen - data lenpublic static String formatBytesStruct(byte[] data)
public static String formatBytesStruct(byte[] data,
int offset,
int len)
data - byte arraypublic static String formatMilliseconds(long ms)
123456 ms --> 00:02:03.456
ms - public static String formatSeconds(long t)
123 s --> 00:02:03
t - public static String formatUtcTime(long utcTime)
public static String stackTraceToSingleLineString(Throwable e,
int maxLines)
e - throwablemaxLines - If greater than zero, returns only first maxLines of tracepublic static String stackTraceToString(Throwable e)
e - throwablepublic static String stackTraceToString(Throwable e,
int maxLines,
String seperator)
e - throwablemaxLines - If greater than zero, returns only first maxLines of traceseperator - character to replace line endings withpublic static String toHex(byte value)
value - byte valuepublic static String toHex(int value)
value - int valuepublic static String toLong(long value)
value - long value