mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
23 lines
853 B
HTML
23 lines
853 B
HTML
<html>
|
|
<body>
|
|
Reports methods and constructors in which constant charset <code>String</code> literal (for example, <code>"UTF-8"</code>) can be replaced with
|
|
the predefined <code>StandardCharsets.UTF_8</code> code.
|
|
<p>The code after the fix may work faster, because the charset lookup becomes unnecessary.
|
|
Also, catching <code>UnsupportedEncodingException</code> may become unnecessary as well. In this case,
|
|
the catch block will be removed automatically.</p>
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
try {
|
|
byte[] bytes = "str".getBytes("UTF-8");
|
|
} catch (UnsupportedEncodingException e) {
|
|
}
|
|
</code></pre>
|
|
<p>After quick-fix is applied:</p>
|
|
<pre><code>
|
|
byte[] bytes = "str".getBytes(StandardCharsets.UTF_8);
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>The inspection is available in Java 7 and later.</p>
|
|
<p><small>New in 2018.2</small></p>
|
|
</body>
|
|
</html> |