# Class StringUtils (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.StringUtils)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.util.StringUtils)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.util.StringUtils)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.util.StringUtils)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.util.StringUtils)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.util.StringUtils)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.util.StringUtils)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.util.StringUtils)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.util.StringUtils)

    public class StringUtils

Utilities for strings.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> StringUtils

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Fields

### LINE_SEPARATOR

    public static final String LINE_SEPARATOR

Line separator to use for this OS, i.e. `"
"` or `"
"`.

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Static Methods

### getBytesUtf8(String string)

    public static 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.
See Also: [Standard charsets](http://download.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `string` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the String to encode, may be `null` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[]` | encoded bytes, or `null` if the input string was `null` |

### newStringUtf8(byte\[\] bytes)

    public static String newStringUtf8(byte[] bytes)

Constructs a new `String` by decoding the specified array of bytes using the UTF-8
charset.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `bytes` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[]` The bytes to be decoded into characters |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | A new `String` decoded from the specified array of bytes using the UTF-8 charset, or `null` if the input byte array was `null`. |