Java encode special character in a String with UTF-8 character
<pre><code> String original = "This is my string valúe";
</code></pre>

<p>I'm trying to encode the above string to UTF-8 equivalent but to replace only special character (ú) with -- "&amp;#250 ;" in this case.</p>

<p>I've tried using the below but I get an error:</p>

<blockquote>
  <p>Input is not proper UTF-8, indicate encoding !Bytes: 0xFA 0x20 0x63 0x61</p>
</blockquote>

<p>Code:</p>

<pre><code>    String original = new String("This is my string valúe");

    byte ptext[] = original.getBytes("UTF-8");
    String value = new String(ptext, "UTF-8"); 

    System.out.println("Output : " + value);

    This is my string valúe
</code></pre>