Class StringUtils
java.lang.Object
com.google.api.client.util.StringUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]getBytesUtf8(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 StringnewStringUtf8(byte[] bytes) Constructs a newStringby decoding the specified array of bytes using the UTF-8 charset.
-
Field Details
-
LINE_SEPARATOR
Line separator to use for this OS, i.e."\n"or"\r\n".- Since:
- 1.8
-
-
Constructor Details
-
StringUtils
private StringUtils()
-
-
Method Details
-
getBytesUtf8
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:
IllegalStateException- Thrown when the charset is missing, which should be never according the Java specification.- Since:
- 1.8
- See Also:
-
newStringUtf8
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:
IllegalStateException- Thrown when aUnsupportedEncodingExceptionis caught, which should never happen since the charset is required.- Since:
- 1.8
-