Class StringUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
abbreviate
(String in, int length) Abbreviates a String using ellipses.static byte[]
base64Decode
(String in) BASE64-decodes the specified string.static String
Shortcut for callingbase64Decode(String) and converting the result to a UTF-8 encoded string.static String
base64Encode
(byte[] in) BASE64-encodes the specified byte array.static String
Shortcut for callingbase64Encode(in.getBytes(
"UTF-8" ))static char
Returns the character at the specified index in the string without throwing exceptions.static int
Compares two strings, but gracefully handlesnulls .static byte[]
Converts string into a GZipped input stream.static boolean
contains
(String value, CharSequence substring) Same asString.contains(CharSequence)
except returnsnull if the value is null.static boolean
containsAny
(String s, char... chars) Returnstrue if the specified string contains any of the specified characters.static int
countChars
(String s, char c) Counts the number of the specified character in the specified string.static String
Debug method for rendering non-ASCII character sequences.static String
decompress
(byte[] is) Converts a GZipped input stream into a string.static int
diffPosition
(String s1, String s2) Finds the position where the two strings differ.static int
diffPositionIc
(String s1, String s2) Finds the position where the two strings differ ignoring case.static boolean
An efficient method for checking if a string ends with a character.static boolean
Same asendsWith(String, char)
except check for multiple characters.static String
escapeChars
(String s, AsciiSet escaped) Escapes the specified characters in the string.static char
Returns the first character in the specified string.static String
firstNonEmpty
(String... s) Returns the first non-null, non-empty string in the list.static char
Returns the first non-whitespace character in the string.static String
Attempts to escape any invalid characters found in a URI.static String
Similar toMessageFormat.format(String, Object...)
except allows you to specify POJO arguments.static byte[]
Converts a hexadecimal character string to a byte array.static String
fromHexToUTF8
(String hex) Converts a hexadecimal byte stream (e.g. "34A5BC") into a UTF-8 encoded string.static byte[]
fromSpacedHex
(String hex) Same asfromHex(String)
except expects spaces between the byte strings.static String
Converts a space-deliminted hexadecimal byte stream (e.g. "34 A5 BC") into a UTF-8 encoded string.static String
Given an absolute URI, returns just the authority portion (e.g.static long
Parses a duration string.static String
Takes in a string, splits it by lines, and then prepends each line with line numbers.static String
getNumberedLines
(String s, int start, int end) Same asgetNumberedLines(String)
except only returns the specified lines.static int
Same asString.indexOf(int)
except allows you to check for multiple characters.static boolean
Efficiently determines whether a URL is of the pattern "xxx://xxx"static boolean
Returnstrue if the specified string is numeric.static boolean
isFirstNumberChar
(char c) Returnstrue if the specified character is a valid first character for a number.static boolean
Returnstrue if the specified string is a floating point number.static boolean
Returnstrue if the specified string is valid JSON.static boolean
isJsonArray
(Object o, boolean ignoreWhitespaceAndComments) Returnstrue if the specified string appears to be an JSON array.static boolean
isJsonObject
(Object o, boolean ignoreWhitespaceAndComments) Returnstrue if the specified string appears to be a JSON object.static boolean
isNumberChar
(char c) Returnstrue if the specified character is a valid number character.static boolean
Returnstrue if this string can be parsed byparseNumber(String, Class)
.static boolean
Returnstrue if the specified string is one of the specified values.static boolean
Efficiently determines whether a URL is of the pattern "xxx:/xxx".static String
Same asUtils.join(Collection, char)
but escapes the delimiter if found in the tokens.static char
Returns the last non-whitespace character in the string.static Character
Converts aString to aCharacter static int
Converts a string containing a possible multiplier suffix to an integer.static Calendar
parseIsoCalendar
(String date) Parses an ISO8601 string into a calendar.static Date
parseIsoDate
(String date) Parses an ISO8601 string into a date.static long
Converts a string containing a possible multiplier suffix to a long.static Number
parseNumber
(String s, Class<? extends Number> type) Parses a number from the specified string.static String
random
(int numchars) Generated a random UUID with the specified number of characters.static String
Creates a repeated pattern.static String
Replaces"\\uXXXX" character sequences with their unicode characters.static String
replaceVars
(String s, Map<String, Object> m) Simple utility for replacing variables of the form"{key}" with values in the specified map.static boolean
startsWith
(String s, char c) An efficient method for checking if a string starts with a character.static String
Converts the specified array to a string.static String
Strips the first and last character from a string.static String
Strips invalid characters such as CTRL characters from a string meant to be encoded as an HTTP header value.static String
Converts the specified object to a comma-delimited list.static String
toHex
(byte b) Converts the specified byte into a 2 hexadecimal characters.static String
toHex
(byte[] bytes) Converts a byte array into a simple hexadecimal character string.static String
toHex
(InputStream is) Converts the contents of the specified input stream to a hex string.static char[]
toHex2
(int num) Converts the specified number into a 2 hexadecimal characters.static char[]
toHex4
(int num) Converts the specified number into a 4 hexadecimal characters.static char[]
toHex8
(long num) Converts the specified number into a 8 hexadecimal characters.static String
Converts the specified object to an ISO8601 date string.static String
Converts the specified object to an ISO8601 date-time string.static String
toReadableBytes
(byte[] b) Converts the specified bytes into a readable string.static String
toSpacedHex
(byte[] bytes) Same astoHex(byte[])
but puts spaces between the byte strings.static URI
Converts the specified object to a URI.static String
toUtf8
(byte[] b) Converts the specified byte array to a UTF-8 string.static String
toUtf8
(InputStream is) Converts the contents of the specified input stream to a UTF-8 string.static String
Same asString.trim()
but preventsNullPointerExceptions .static String
Trims whitespace characters from the end of the specified string.static String
Trims'/' characters from the beginning of the specified string.static String
Trims'/' characters from both the start and end of the specified string.static String
Trims'/' and space characters from both the start and end of the specified string.static String
Trims whitespace characters from the beginning of the specified string.static String
Trims'/' characters from the end of the specified string.static String
unEscapeChars
(String s, AsciiSet escaped) Removes escape characters from the specified characters.static String
unicodeSequence
(char c) Creates an escaped-unicode sequence (e.g.static String
Decodes aapplication/x-www-form-urlencoded string usingUTF-8 encoding scheme.static String
Encodes aapplication/x-www-form-urlencoded string usingUTF-8 encoding scheme.static String
Same asurlEncode(String)
except only escapes characters that absolutely need to be escaped.static String
Similar toURLEncoder.encode(String, String)
but doesn't encode"/" characters.
-
Field Details
-
NOT_EMPTY
Predicate check to filter out null and empty strings.
-
-
Constructor Details
-
StringUtils
protected StringUtils()Constructor.
-
-
Method Details
-
abbreviate
Abbreviates a String using ellipses.- Parameters:
in
- The input string.length
- The max length of the resulting string.- Returns:
- The abbreviated string.
-
base64Decode
BASE64-decodes the specified string.- Parameters:
in
- The BASE-64 encoded string.- Returns:
- The decoded byte array, or null if the input was
null .
-
base64DecodeToString
Shortcut for callingbase64Decode(String) and converting the result to a UTF-8 encoded string.- Parameters:
in
- The BASE-64 encoded string to decode.- Returns:
- The decoded string.
-
base64Encode
BASE64-encodes the specified byte array.- Parameters:
in
- The input byte array to convert.- Returns:
- The byte array converted to a BASE-64 encoded string.
-
base64EncodeToString
Shortcut for callingbase64Encode(in.getBytes(
"UTF-8" ))- Parameters:
in
- The input string to convert.- Returns:
- The string converted to BASE-64 encoding.
-
charAt
Returns the character at the specified index in the string without throwing exceptions.- Parameters:
s
- The string.i
- The index position.- Returns:
- The character at the specified index, or
0 if the index is out-of-range or the string isnull .
-
compare
Compares two strings, but gracefully handlesnulls .- Parameters:
s1
- The first string.s2
- The second string.- Returns:
- The same as
String.compareTo(String)
.
-
compress
Converts string into a GZipped input stream.- Parameters:
contents
- The contents to compress.- Returns:
- The input stream converted to GZip.
- Throws:
Exception
- Exception occurred.
-
contains
Same asString.contains(CharSequence)
except returnsnull if the value is null.- Parameters:
value
- The string to check.substring
- The value to check for.- Returns:
true if the value contains the specified substring.
-
containsAny
Returnstrue if the specified string contains any of the specified characters.- Parameters:
s
- The string to test.chars
- The characters to look for.- Returns:
true if the specified string contains any of the specified characters.false if the string isnull .
-
countChars
Counts the number of the specified character in the specified string.- Parameters:
s
- The string to check.c
- The character to check for.- Returns:
- The number of those characters or zero if the string was
null .
-
decodeHex
Debug method for rendering non-ASCII character sequences.- Parameters:
s
- The string to decode.- Returns:
- A string with non-ASCII characters converted to
"[hex]" sequences.
-
decompress
Converts a GZipped input stream into a string.- Parameters:
is
- The contents to decompress.- Returns:
- The string.
- Throws:
Exception
- Exception occurred.
-
diffPosition
Finds the position where the two strings differ.- Parameters:
s1
- The first string.s2
- The second string.- Returns:
- The position where the two strings differ, or
-1 if they're equal.
-
diffPositionIc
Finds the position where the two strings differ ignoring case.- Parameters:
s1
- The first string.s2
- The second string.- Returns:
- The position where the two strings differ, or
-1 if they're equal.
-
endsWith
An efficient method for checking if a string ends with a character.- Parameters:
s
- The string to check. Can benull .c
- The character to check for.- Returns:
true if the specified string is notnull and ends with the specified character.
-
endsWith
Same asendsWith(String, char)
except check for multiple characters.- Parameters:
s
- The string to check. Can benull .c
- The characters to check for.- Returns:
true if the specified string is notnull and ends with the specified character.
-
escapeChars
Escapes the specified characters in the string.- Parameters:
s
- The string with characters to escape.escaped
- The characters to escape.- Returns:
- The string with characters escaped, or the same string if no escapable characters were found.
-
firstChar
Returns the first character in the specified string.- Parameters:
s
- The string to check.- Returns:
- The first character in the string, or
0 if the string isnull or empty.
-
firstNonEmpty
Returns the first non-null, non-empty string in the list.- Parameters:
s
- The strings to test.- Returns:
- The first non-empty string in the list, or
null if they were allnull or empty.
-
firstNonWhitespaceChar
Returns the first non-whitespace character in the string.- Parameters:
s
- The string to check.- Returns:
- The first non-whitespace character, or
0 if the string isnull , empty, or composed of only whitespace.
-
fixUrl
Attempts to escape any invalid characters found in a URI.- Parameters:
in
- The URI to fix.- Returns:
- The fixed URI.
-
format
Similar toMessageFormat.format(String, Object...)
except allows you to specify POJO arguments.- Parameters:
pattern
- The string pattern.args
- The arguments.- Returns:
- The formatted string.
-
fromHex
Converts a hexadecimal character string to a byte array.- Parameters:
hex
- The string to convert to a byte array.- Returns:
- A new byte array.
-
fromHexToUTF8
Converts a hexadecimal byte stream (e.g. "34A5BC") into a UTF-8 encoded string.- Parameters:
hex
- The hexadecimal string.- Returns:
- The UTF-8 string.
-
fromSpacedHex
Same asfromHex(String)
except expects spaces between the byte strings.- Parameters:
hex
- The string to convert to a byte array.- Returns:
- A new byte array.
-
fromSpacedHexToUTF8
Converts a space-deliminted hexadecimal byte stream (e.g. "34 A5 BC") into a UTF-8 encoded string.- Parameters:
hex
- The hexadecimal string.- Returns:
- The UTF-8 string.
-
getAuthorityUri
Given an absolute URI, returns just the authority portion (e.g."http://hostname:port" )- Parameters:
s
- The URI string.- Returns:
- Just the authority portion of the URI.
-
getDuration
Parses a duration string.Examples:
"1000" - 1000 milliseconds."10s" - 10 seconds."10 sec" - 10 seconds."10 seconds" - 10 seconds.
Use any of the following suffixes:
- None (time in milliseconds).
"s" /"sec" /"second" /"seconds" "m" /"min" /"minutes" /"seconds" "h" /"hour" /"hours" "d" /"day" /"days" "w" /"week" /"weeks"
Suffixes are case-insensitive.
Whitespace is ignored.- Parameters:
s
- The string to parse.- Returns:
- The time in milliseconds, or
-1 if the string is empty ornull .
-
getNumberedLines
Takes in a string, splits it by lines, and then prepends each line with line numbers.- Parameters:
s
- The string.- Returns:
- The string with line numbers added.
-
getNumberedLines
Same asgetNumberedLines(String)
except only returns the specified lines.Out-of-bounds values are allowed and fixed.
- Parameters:
s
- The string.start
- The starting line (1-indexed).end
- The ending line (1-indexed).- Returns:
- The string with line numbers added.
-
indexOf
Same asString.indexOf(int)
except allows you to check for multiple characters.- Parameters:
s
- The string to check.c
- The characters to check for.- Returns:
- The index into the string that is one of the specified characters.
-
isAbsoluteUri
Efficiently determines whether a URL is of the pattern "xxx://xxx"- Parameters:
s
- The string to test.- Returns:
true if it's an absolute path.
-
isDecimal
Returnstrue if the specified string is numeric.- Parameters:
s
- The string to check.- Returns:
true if the specified string is numeric.
-
isFirstNumberChar
Returnstrue if the specified character is a valid first character for a number.- Parameters:
c
- The character to test.- Returns:
true if the specified character is a valid first character for a number.
-
isFloat
Returnstrue if the specified string is a floating point number.- Parameters:
s
- The string to check.- Returns:
true if the specified string is a floating point number.
-
isJson
Returnstrue if the specified string is valid JSON.Leading and trailing spaces are ignored.
Leading and trailing comments are not allowed.- Parameters:
s
- The string to test.- Returns:
true if the specified string is valid JSON.
-
isJsonArray
Returnstrue if the specified string appears to be an JSON array.- Parameters:
o
- The object to test.ignoreWhitespaceAndComments
- Iftrue , leading and trailing whitespace and comments will be ignored.- Returns:
true if the specified string appears to be a JSON array.
-
isJsonObject
Returnstrue if the specified string appears to be a JSON object.- Parameters:
o
- The object to test.ignoreWhitespaceAndComments
- Iftrue , leading and trailing whitespace and comments will be ignored.- Returns:
true if the specified string appears to be a JSON object.
-
isNumberChar
Returnstrue if the specified character is a valid number character.- Parameters:
c
- The character to check.- Returns:
true if the specified character is a valid number character.
-
isNumeric
Returnstrue if this string can be parsed byparseNumber(String, Class)
.- Parameters:
s
- The string to check.- Returns:
true if this string can be parsed without causing an exception.
-
isOneOf
Returnstrue if the specified string is one of the specified values.- Parameters:
s
- The string to test. Can benull .values
- The values to test. Can containnull .- Returns:
true if the specified string is one of the specified values.
-
isUri
Efficiently determines whether a URL is of the pattern "xxx:/xxx".The pattern matched is:
[a-z]{2,}\:\/.* Note that this excludes filesystem paths such as
"C:/temp" .- Parameters:
s
- The string to test.- Returns:
true if it's an absolute path.
-
joine
Same asUtils.join(Collection, char)
but escapes the delimiter if found in the tokens.- Parameters:
tokens
- The tokens to join.d
- The delimiter.- Returns:
- The delimited string. If
tokens isnull , returnsnull .
-
lastNonWhitespaceChar
Returns the last non-whitespace character in the string.- Parameters:
s
- The string to check.- Returns:
- The last non-whitespace character, or
0 if the string isnull , empty, or composed of only whitespace.
-
parseCharacter
Converts aString to aCharacter - Parameters:
o
- The string to convert.- Returns:
- The first character of the string if the string is of length 1, or
null if the string isnull or empty. - Throws:
IllegalArgumentException
- If the string length is not 1.
-
parseIntWithSuffix
Converts a string containing a possible multiplier suffix to an integer.The string can contain any of the following multiplier suffixes:
"K" - x 1024"M" - x 1024*1024"G" - x 1024*1024*1024"k" - x 1000"m" - x 1000*1000"g" - x 1000*1000*1000
- Parameters:
s
- The string to parse.- Returns:
- The parsed value.
-
parseIsoCalendar
Parses an ISO8601 string into a calendar.Supports any of the following formats:
yyyy, yyyy-MM, yyyy-MM-dd, yyyy-MM-ddThh, yyyy-MM-ddThh:mm, yyyy-MM-ddThh:mm:ss, yyyy-MM-ddThh:mm:ss.SSS - Parameters:
date
- The date string.- Returns:
- The parsed calendar.
- Throws:
IllegalArgumentException
- Value was not a valid date.
-
parseIsoDate
Parses an ISO8601 string into a date.Supports any of the following formats:
yyyy, yyyy-MM, yyyy-MM-dd, yyyy-MM-ddThh, yyyy-MM-ddThh:mm, yyyy-MM-ddThh:mm:ss, yyyy-MM-ddThh:mm:ss.SSS - Parameters:
date
- The date string.- Returns:
- The parsed date.
- Throws:
IllegalArgumentException
- Value was not a valid date.
-
parseLongWithSuffix
Converts a string containing a possible multiplier suffix to a long.The string can contain any of the following multiplier suffixes:
"K" - x 1024"M" - x 1024*1024"G" - x 1024*1024*1024"T" - x 1024*1024*1024*1024"P" - x 1024*1024*1024*1024*1024"k" - x 1000"m" - x 1000*1000"g" - x 1000*1000*1000"t" - x 1000*1000*1000*1000"p" - x 1000*1000*1000*1000*1000
- Parameters:
s
- The string to parse.- Returns:
- The parsed value.
-
parseNumber
Parses a number from the specified string.- Parameters:
s
- The string to parse the number from.type
- The number type to created. Can be any of the following:- Integer
- Double
- Float
- Long
- Short
- Byte
- BigInteger
- BigDecimal
null orNumber , uses the best guess.- Returns:
- The parsed number, or
null if the string was null.
-
random
Generated a random UUID with the specified number of characters.Characters are composed of lower-case ASCII letters and numbers only.
This method conforms to the restrictions for hostnames as specified in RFC 952 Since each character has 36 possible values, the square approximation formula for the number of generated IDs that would produce a 50% chance of collision is:
sqrt(36^N) . Dividing this number by 10 gives you an approximation of the number of generated IDs needed to produce a <1% chance of collision.For example, given 5 characters, the number of generated IDs need to produce a <1% chance of collision would be:
sqrt(36^5)/10=777 - Parameters:
numchars
- The number of characters in the generated UUID.- Returns:
- A new random UUID.
-
repeat
Creates a repeated pattern.- Parameters:
count
- The number of times to repeat the pattern.pattern
- The pattern to repeat.- Returns:
- A new string consisting of the repeated pattern.
-
replaceUnicodeSequences
Replaces"\\uXXXX" character sequences with their unicode characters.- Parameters:
s
- The string to replace unicode sequences in.- Returns:
- A string with unicode sequences replaced.
-
replaceVars
Simple utility for replacing variables of the form"{key}" with values in the specified map.Nested variables are supported in both the input string and map values.
If the map does not contain the specified value, the variable is not replaced.
null values in the map are treated as blank strings.- Parameters:
s
- The string containing variables to replace.m
- The map containing the variable values.- Returns:
- The new string with variables replaced, or the original string if it didn't have variables in it.
-
startsWith
An efficient method for checking if a string starts with a character.- Parameters:
s
- The string to check. Can benull .c
- The character to check for.- Returns:
true if the specified string is notnull and starts with the specified character.
-
stringifyDeep
Converts the specified array to a string.- Parameters:
o
- The array to convert to a string.- Returns:
- The array converted to a string, or
null if the object was null.
-
strip
Strips the first and last character from a string.- Parameters:
s
- The string to strip.- Returns:
- The striped string, or the same string if the input was
null or less than length 2.
-
stripInvalidHttpHeaderChars
Strips invalid characters such as CTRL characters from a string meant to be encoded as an HTTP header value.- Parameters:
s
- The string to strip chars from.- Returns:
- The string with invalid characters removed.
-
toCdl
Converts the specified object to a comma-delimited list.- Parameters:
o
- The object to convert.- Returns:
- The specified object as a comma-delimited list.
-
toHex
Converts the specified byte into a 2 hexadecimal characters.- Parameters:
b
- The number to convert to hex.- Returns:
- A
containing the specified characters.char [2]
-
toHex
Converts a byte array into a simple hexadecimal character string.- Parameters:
bytes
- The bytes to convert to hexadecimal.- Returns:
- A new string consisting of hexadecimal characters.
-
toHex
Converts the contents of the specified input stream to a hex string.- Parameters:
is
- The input stream to convert.- Returns:
- The hex string representation of the input stream contents, or
null if the stream isnull .
-
toHex2
Converts the specified number into a 2 hexadecimal characters.- Parameters:
num
- The number to convert to hex.- Returns:
- A
containing the specified characters.char [2]
-
toHex4
Converts the specified number into a 4 hexadecimal characters.- Parameters:
num
- The number to convert to hex.- Returns:
- A
containing the specified characters.char [4]
-
toHex8
Converts the specified number into a 8 hexadecimal characters.- Parameters:
num
- The number to convert to hex.- Returns:
- A
containing the specified characters.char [8]
-
toIsoDate
Converts the specified object to an ISO8601 date string.- Parameters:
c
- The object to convert.- Returns:
- The converted object.
-
toIsoDateTime
Converts the specified object to an ISO8601 date-time string.- Parameters:
c
- The object to convert.- Returns:
- The converted object.
-
toReadableBytes
Converts the specified bytes into a readable string.- Parameters:
b
- The number to convert to hex.- Returns:
- A
containing the specified characters.char [2]
-
toSpacedHex
Same astoHex(byte[])
but puts spaces between the byte strings.- Parameters:
bytes
- The bytes to convert to hexadecimal.- Returns:
- A new string consisting of hexadecimal characters.
-
toURI
Converts the specified object to a URI.- Parameters:
o
- The object to convert to a URI.- Returns:
- A new URI, or the same object if the object was already a URI, or
-
toUtf8
Converts the specified byte array to a UTF-8 string.- Parameters:
b
- The byte array to convert.- Returns:
- The UTF-8 string representation, or
null if the array isnull .
-
toUtf8
Converts the contents of the specified input stream to a UTF-8 string.- Parameters:
is
- The input stream to convert.- Returns:
- The UTF-8 string representation of the input stream contents, or
null if the stream isnull .
-
trim
Same asString.trim()
but preventsNullPointerExceptions .- Parameters:
s
- The string to trim.- Returns:
- The trimmed string, or
null if the string wasnull .
-
trimEnd
Trims whitespace characters from the end of the specified string.- Parameters:
s
- The string to trim.- Returns:
- The trimmed string, or
null if the string wasnull .
-
trimLeadingSlashes
Trims'/' characters from the beginning of the specified string.- Parameters:
s
- The string to trim.- Returns:
- A new trimmed string, or the same string if no trimming was necessary.
-
trimSlashes
Trims'/' characters from both the start and end of the specified string.- Parameters:
s
- The string to trim.- Returns:
- A new trimmed string, or the same string if no trimming was necessary.
-
trimSlashesAndSpaces
Trims'/' and space characters from both the start and end of the specified string.- Parameters:
s
- The string to trim.- Returns:
- A new trimmed string, or the same string if no trimming was necessary.
-
trimStart
Trims whitespace characters from the beginning of the specified string.- Parameters:
s
- The string to trim.- Returns:
- The trimmed string, or
null if the string wasnull .
-
trimTrailingSlashes
Trims'/' characters from the end of the specified string.- Parameters:
s
- The string to trim.- Returns:
- A new trimmed string, or the same string if no trimming was necessary.
-
unEscapeChars
Removes escape characters from the specified characters.- Parameters:
s
- The string to remove escape characters from.escaped
- The characters escaped.- Returns:
- A new string if characters were removed, or the same string if not or if the input was
null .
-
unicodeSequence
Creates an escaped-unicode sequence (e.g."\\u1234" ) for the specified character.- Parameters:
c
- The character to create a sequence for.- Returns:
- An escaped-unicode sequence.
-
urlDecode
Decodes aapplication/x-www-form-urlencoded string usingUTF-8 encoding scheme.- Parameters:
s
- The string to decode.- Returns:
- The decoded string, or
null if input isnull .
-
urlEncode
Encodes aapplication/x-www-form-urlencoded string usingUTF-8 encoding scheme.- Parameters:
s
- The string to encode.- Returns:
- The encoded string, or
null if input isnull .
-
urlEncodeLax
Same asurlEncode(String)
except only escapes characters that absolutely need to be escaped.- Parameters:
s
- The string to escape.- Returns:
- The encoded string, or
null if input isnull .
-
urlEncodePath
Similar toURLEncoder.encode(String, String)
but doesn't encode"/" characters.- Parameters:
o
- The object to encode.- Returns:
- The URL encoded string, or
null if the object was null.
-