public class StringUtils extends Object
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
arrayToString(String[] strs)
Given an array of strings, return a comma-separated list of its elements.
|
static String |
byteToHexString(byte[] bytes)
Given an array of bytes it will convert the bytes to a hex string
representation of the bytes
|
static String |
formatPercent(double done,
int digits)
Format a percentage for presentation to the user.
|
static String |
formatTimeDiff(long finishTime,
long startTime)
Given a finish and start time in long milliseconds, returns a
String in the format Xhrs, Ymins, Z sec, for the time difference between two times.
|
static String |
getFormattedTimeWithDiff(DateFormat dateFormat,
long finishTime,
long startTime)
Formats time in ms and appends difference (finishTime - startTime)
as returned by formatTimeDiff().
|
static String[] |
getStrings(String str)
returns an arraylist of strings
|
static byte[] |
hexStringToByte(String hex)
Given a hexstring this will return the byte array corresponding to the
string
|
static String |
humanReadableInt(long number)
Given an integer, return a string that is in an approximate, but human
readable format.
|
static String |
simpleHostname(String fullHostname)
Given a full hostname, return the word upto the first dot.
|
static String |
stringifyException(Throwable e)
Make a string representation of the exception.
|
static Path[] |
stringToPath(String[] str) |
static URI[] |
stringToURI(String[] str) |
static String |
uriToString(URI[] uris) |
public static String stringifyException(Throwable e)
e
- The exception to stringifypublic static String simpleHostname(String fullHostname)
fullHostname
- the full hostnamepublic static String humanReadableInt(long number)
number
- the number to formatpublic static String formatPercent(double done, int digits)
done
- the percentage to format (0.0 to 1.0)digits
- the number of digits past the decimal pointpublic static String arrayToString(String[] strs)
strs
- Array of stringspublic static String byteToHexString(byte[] bytes)
bytes
- public static byte[] hexStringToByte(String hex)
hex
- the hex String arraypublic static String formatTimeDiff(long finishTime, long startTime)
finishTime
- finish timestartTime
- start timepublic static String getFormattedTimeWithDiff(DateFormat dateFormat, long finishTime, long startTime)
dateFormat
- date format to usefinishTime
- fnish timestartTime
- start timeCopyright © 2007, 2014, Oracle and/or its affiliates. All rights reserved.