Package com.google.api.client.util
Class StringUtils
- java.lang.Object
-
- com.google.api.client.util.StringUtils
-
public class StringUtils extends java.lang.ObjectUtilities for strings.Some of these methods are a proxy for version 1.6 (or newer) of the Apache Commons Codec
StringUtilsimplementation. This is needed in order to support platforms like Android which already include an older version of the Apache Commons Codec (Android includes version 1.3). To avoid a dependency library conflict, this library includes a reduced private copy of version 1.6 (or newer) of the Apache Commons Codec (using a tool like jarjar).- Since:
- 1.8
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLINE_SEPARATORLine separator to use for this OS, i.e.
-
Constructor Summary
Constructors Modifier Constructor Description privateStringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]getBytesUtf8(java.lang.String string)Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte array.static java.lang.StringnewStringUtf8(byte[] bytes)Constructs a newStringby decoding the specified array of bytes using the UTF-8 charset.
-
-
-
Method Detail
-
getBytesUtf8
public static byte[] getBytesUtf8(java.lang.String string)
Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte array.- Parameters:
string- the String to encode, may benull- Returns:
- encoded bytes, or
nullif the input string wasnull - Throws:
java.lang.IllegalStateException- Thrown when the charset is missing, which should be never according the the Java specification.- Since:
- 1.8
- See Also:
- Standard charsets,
StringUtils.getBytesUtf8(String)
-
newStringUtf8
public static java.lang.String newStringUtf8(byte[] bytes)
Constructs a newStringby decoding the specified array of bytes using the UTF-8 charset.- Parameters:
bytes- The bytes to be decoded into characters- Returns:
- A new
Stringdecoded from the specified array of bytes using the UTF-8 charset, ornullif the input byte array wasnull. - Throws:
java.lang.IllegalStateException- Thrown when aUnsupportedEncodingExceptionis caught, which should never happen since the charset is required.- Since:
- 1.8
- See Also:
StringUtils.newStringUtf8(byte[])
-
-