public class StringUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
__ISO_8859_1 |
static Charset |
__ISO_8859_1_CHARSET
Deprecated.
|
static String |
__LINE_SEPARATOR
Deprecated.
use
System.lineSeparator() instead |
static Charset |
__US_ASCII_CHARSET
Deprecated.
|
static String |
__UTF16 |
static Charset |
__UTF16_CHARSET
Deprecated.
|
static String |
__UTF8 |
static Charset |
__UTF8_CHARSET
Deprecated.
|
static String |
ALL_INTERFACES |
static String |
CRLF |
static char[] |
lowercases |
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
append(StringBuilder buf,
byte b,
int base)
append hex digit
|
static void |
append(StringBuilder buf,
String s,
int offset,
int length)
Append substring to StringBuilder
|
static void |
append2digits(StringBuffer buf,
int i) |
static void |
append2digits(StringBuilder buf,
int i) |
static String[] |
arrayFromString(String s) |
static String |
asciiToLowerCase(String s)
fast lower case conversion.
|
static boolean |
endsWithIgnoreCase(String s,
String w) |
static boolean |
equals(String s,
char[] buf,
int offset,
int length) |
static byte[] |
getBytes(String s) |
static byte[] |
getBytes(String s,
String charset) |
static byte[] |
getUtf8Bytes(String s) |
static int |
indexFrom(String s,
String chars)
returns the next index of a character from the chars string
|
static boolean |
isBlank(String str)
Test if a string is null or only has whitespace characters in it.
|
static boolean |
isNotBlank(String str)
Test if a string is not null and contains at least 1 non-whitespace characters in it.
|
static boolean |
isUTF8(String charset) |
static String |
nonNull(String s)
Return a non null string.
|
static String |
normalizeCharset(String s)
Convert alternate charset names (eg utf8) to normalized
name (eg UTF-8).
|
static String |
normalizeCharset(String s,
int offset,
int length)
Convert alternate charset names (eg utf8) to normalized
name (eg UTF-8).
|
static String |
printable(byte[] b) |
static String |
printable(String name) |
static String |
replace(String s,
String sub,
String with)
replace substrings within string.
|
static String |
sidBytesToString(byte[] sidBytes)
Converts a binary SID to a string SID
http://en.wikipedia.org/wiki/Security_Identifier
S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn
|
static byte[] |
sidStringToBytes(String sidString)
Converts a string SID to a binary SID
http://en.wikipedia.org/wiki/Security_Identifier
S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn
|
static boolean |
startsWithIgnoreCase(String s,
String w) |
static int |
toInt(String string)
Convert String to an integer.
|
static long |
toLong(String string)
Convert String to an long.
|
static String |
toString(byte[] b,
int offset,
int length,
String charset) |
static String |
toUTF8String(byte[] b,
int offset,
int length) |
static String |
truncate(String str,
int maxSize)
Truncate a string to a max size.
|
static String |
unquote(String s)
Remove single or double quotes.
|
public static final String ALL_INTERFACES
public static final String CRLF
@Deprecated public static final String __LINE_SEPARATOR
System.lineSeparator()
insteadpublic static final String __ISO_8859_1
public static final String __UTF8
public static final String __UTF16
@Deprecated public static final Charset __UTF8_CHARSET
StandardCharsets.UTF_8
@Deprecated public static final Charset __ISO_8859_1_CHARSET
StandardCharsets.ISO_8859_1
@Deprecated public static final Charset __UTF16_CHARSET
StandardCharsets.UTF_16
@Deprecated public static final Charset __US_ASCII_CHARSET
StandardCharsets.US_ASCII
public static final char[] lowercases
public static String normalizeCharset(String s)
public static String normalizeCharset(String s, int offset, int length)
public static String asciiToLowerCase(String s)
s
- the string to convertpublic static int indexFrom(String s, String chars)
public static String replace(String s, String sub, String with)
public static void append(StringBuilder buf, String s, int offset, int length)
buf
- StringBuilder to append tos
- String to append fromoffset
- The offset of the substringlength
- The length of the substringpublic static void append(StringBuilder buf, byte b, int base)
public static void append2digits(StringBuffer buf, int i)
public static void append2digits(StringBuilder buf, int i)
public static String nonNull(String s)
s
- Stringpublic static boolean equals(String s, char[] buf, int offset, int length)
public static String toUTF8String(byte[] b, int offset, int length)
public static boolean isBlank(String str)
Note: uses codepoint version of Character.isWhitespace(int)
to support Unicode better.
isBlank(null) == true isBlank("") == true isBlank("\r\n") == true isBlank("\t") == true isBlank(" ") == true isBlank("a") == false isBlank(".") == false isBlank(";\n") == false
str
- the string to test.public static boolean isNotBlank(String str)
Note: uses codepoint version of Character.isWhitespace(int)
to support Unicode better.
isNotBlank(null) == false isNotBlank("") == false isNotBlank("\r\n") == false isNotBlank("\t") == false isNotBlank(" ") == false isNotBlank("a") == true isNotBlank(".") == true isNotBlank(";\n") == true
str
- the string to test.public static boolean isUTF8(String charset)
public static String printable(byte[] b)
public static byte[] getBytes(String s)
public static byte[] getUtf8Bytes(String s)
public static String sidBytesToString(byte[] sidBytes)
public static byte[] sidStringToBytes(String sidString)
public static int toInt(String string)
string
- A String containing an integer.public static long toLong(String string)
string
- A String containing an integer.public static String truncate(String str, int maxSize)
str
- the string to possibly truncatemaxSize
- the maximum size of the stringstr
param is null, then the returned string will also be null.Copyright © 1995-2015 Webtide. All Rights Reserved.