public final class StringUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
count(String string,
String toSearch)
Count the number of occurences.
|
static int |
decodeHexa(char c)
Return the integer value of the given hexadecimal digit, or -1 if it is not an hexadecimal digit.
|
static byte[] |
decodeHexa(String s)
Decode a string containing hexadecimal digits into an array of bytes.
|
static void |
decodeHexa(String s,
byte[] data)
Decode a string containing hexadecimal digits into the given array of bytes.
|
static byte |
decodeHexaByte(String hexa)
Decode the given hexadecimal string into a byte (the string must contain 1 or 2 hexa digits).
|
static long |
decodeHexaLong(String hexa)
Decode the given string containing hexadecimal digits into a long value.
|
static String |
duration(long ms)
Create a string for the given duration.
|
static String |
encodeHexa(byte b)
Encode the given byte into hexadecimal.
|
static String |
encodeHexa(byte[] data)
Encode the given bytes into hexadecimal.
|
static String |
encodeHexa(byte[] data,
int off,
int len)
Encode the given bytes into hexadecimal.
|
static char |
encodeHexaDigit(int value)
Encode a single hexadecimal digit (given value must be between 0 and 15).
|
static String |
encodeHexaPadding(long value)
Encode a long value into hexadecimal, padding with zeros to create a string of 16 characters.
|
static boolean |
isHexa(char c) |
static StringBuilder |
paddingLeft(StringBuilder s,
int length,
char padding)
Insert padding character to a StringBuilder.
|
static StringBuilder |
paddingLeft(StringBuilder s,
long value,
int fixedSize)
Convert the long to a string and append spaces up to the given fixed size.
|
static StringBuilder |
paddingLeft(StringBuilder to,
String s,
int length,
char padding)
Add the string and insert padding character to a StringBuilder.
|
static StringBuilder |
paddingRight(StringBuilder s,
int length,
char padding)
Append padding character until the StringBuilder has the given length.
|
static StringBuilder |
paddingRight(StringBuilder s,
long value,
int fixedSize)
Convert the long to a string and append spaces up to the given fixed size.
|
static StringBuilder |
paddingRight(StringBuilder to,
String s,
int nb,
char padding)
Append padding character until the StringBuilder has the given length.
|
static long |
parseSize(String s)
Parse the given string containing a size with a unit (B for bytes, K for KB...).
|
static String |
possibleValues(Class<? extends Enum<?>> e)
Create a string containing all enumeration values separated by a comma, for printing or debugging purpose.
|
static String |
size(BigInteger s)
Create a string for the given size, expressed in bytes or KB or MB or GB or TB, with 2 decimals.
|
static String |
size(long size)
Create a string for the given size, expressed in bytes or KB or MB or GB or TB, with 2 decimals.
|
static String |
size(Number size)
Create a string for the given size, expressed in bytes or KB or MB or GB or TB, with 2 decimals.
|
public static StringBuilder paddingLeft(StringBuilder s, int length, char padding)
public static StringBuilder paddingLeft(StringBuilder to, String s, int length, char padding)
public static StringBuilder paddingLeft(StringBuilder s, long value, int fixedSize)
public static StringBuilder paddingRight(StringBuilder s, int length, char padding)
public static StringBuilder paddingRight(StringBuilder to, String s, int nb, char padding)
public static StringBuilder paddingRight(StringBuilder s, long value, int fixedSize)
public static char encodeHexaDigit(int value)
public static String encodeHexa(byte[] data)
public static String encodeHexa(byte[] data, int off, int len)
public static String encodeHexa(byte b)
public static String encodeHexaPadding(long value)
public static byte[] decodeHexa(String s)
public static void decodeHexa(String s, byte[] data)
public static int decodeHexa(char c)
public static byte decodeHexaByte(String hexa)
public static long decodeHexaLong(String hexa)
public static boolean isHexa(char c)
public static String possibleValues(Class<? extends Enum<?>> e)
public static String size(long size)
public static String size(Number size)
public static String size(BigInteger s)
public static long parseSize(String s) throws ParseException
ParseExceptionpublic static String duration(long ms)
Copyright © 2019. All rights reserved.