public class StringBuilderUtil extends Object
| Constructor and Description |
|---|
StringBuilderUtil() |
| Modifier and Type | Method and Description |
|---|---|
static StringBuilder |
appendHex(StringBuilder buf,
int value,
int width)
Converts the passed value into hexadecimal representation, and appends
that representation to the buffer, left-zero-padded.
|
static StringBuilder |
appendRepeat(StringBuilder buf,
char c,
int count)
Appends N copies of the same character to the end of a builder.
|
static StringBuilder |
appendUnless(StringBuilder sb,
String test,
String str)
Appends the passed string to a
StringBuilder, unless
it ends with the test string. |
static char |
lastChar(StringBuilder buf)
Returns the last character in the passed
StringBuilder,
'\0' if passed null or the builder's length is 0. |
public static StringBuilder appendRepeat(StringBuilder buf, char c, int count)
public static StringBuilder appendHex(StringBuilder buf, int value, int width)
buf - The buffer to be updated.value - The value to be converted.width - Size of the field that will hold the value. If the hex
representation of the value is smaller, it will be
left-zero-padded; if greater, the high-order bits will
be truncated.public static char lastChar(StringBuilder buf)
StringBuilder,
'\0' if passed null or the builder's length is 0.public static StringBuilder appendUnless(StringBuilder sb, String test, String str)
StringBuilder, unless
it ends with the test string. This is useful when constructing a
string from repeated values, where you want all but the first to
be separated by a comma.sb - The builder to be updated.test - The test string.str - The string to append unless the builder ends
with the test string.StringBuilder, as a convenience for callers.