<p>I get the following warning when using <code>java.net.URLEncoder.encode</code>:</p>

<pre>warning: [deprecation] encode(java.lang.String)
         in java.net.URLEncoder has been deprecated</pre>

<p>What should I be using instead?</p>

Use the other
```
encode
```
method in
URLEncoder
:
```
```
URLEncoder.encode(String, String)
```
```
The first parameter is the text to encode; the second is the name of the character encoding to use (e.g.,
```
UTF-8
```
). For example:
```
```
System.out.println(
  URLEncoder.encode(
    "urlParameterString",
    java.nio.charset.StandardCharsets.UTF_8.toString()
  )
);
```
```