@ThreadSafe public final class FormatUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
byteArrayToHexString(byte[] bytes)
Parses a byte array into a space separated hex string where each byte is represented in the
format
0x%02x . |
static String |
byteArrayToHexString(byte[] bytes,
String prefix,
String separator)
Parses a byte array into a hex string where each byte is represented in the
format
%02x . |
static String |
byteBufferToString(ByteBuffer buf)
Parses a
ByteBuffer into a String . |
static String |
formatMode(short mode,
boolean directory,
boolean hasExtended)
Formats digital representation of a model as a human-readable string.
|
static String |
formatTimeTakenMs(long startTimeMs,
String message)
Formats time elapsed since the given start time (in milliseconds).
|
static String |
formatTimeTakenNs(long startTimeNs,
String message)
Formats time elapsed since the given start time (in nanoseconds).
|
static String |
getSizeFromBytes(long bytes)
Returns a human-readable version of bytes 10GB 2048KB etc.
|
static String |
parametersToString(Object... objs)
Parses a list of
Objects into a String . |
static long |
parseSpaceSize(String spaceSize)
Parses a String size to Bytes.
|
static long |
parseTimeSize(String timeSize)
Parses a String size to Milliseconds.
|
public static String parametersToString(Object... objs)
Objects
into a String
.objs
- a list of Objects to convert to a Stringpublic static String byteBufferToString(ByteBuffer buf)
ByteBuffer
into a String
. In particular, the function prints the
content of the buffer in 4-byte increments as space separated integers.buf
- buffer to useByteBuffer
public static String byteArrayToHexString(byte[] bytes)
0x%02x
.bytes
- the byte array to be transformedpublic static String byteArrayToHexString(byte[] bytes, String prefix, String separator)
%02x
.bytes
- the byte array to be transformedprefix
- the prefix to useseparator
- the separator to usepublic static String formatTimeTakenMs(long startTimeMs, String message)
startTimeMs
- start time in millisecondsmessage
- prefix for the message to be printedpublic static String formatTimeTakenNs(long startTimeNs, String message)
startTimeNs
- start time in nanosecondsmessage
- prefix for the message to be printedpublic static String getSizeFromBytes(long bytes)
bytes
- the number of bytespublic static long parseSpaceSize(String spaceSize)
spaceSize
- the size of a space, e.g. 10GB, 5TB, 1024public static long parseTimeSize(String timeSize)
timeSize
- the size of a time, e.g. 1M, 5H, 10D, -1public static String formatMode(short mode, boolean directory, boolean hasExtended)
mode
- file modedirectory
- if the mode corresponds to a directoryhasExtended
- true if extended acls existCopyright © 2023. All Rights Reserved.