Convert byte array or strinbuilder to utf-8
<p>i want to convert the content to utf-8 charset before i return the string in following method:</p>

<pre><code>public static String getContentResult(URL url) throws IOException{
    InputStream in = url.openStream();
    StringBuilder sb = new StringBuilder();

    byte [] buffer = new byte[4096];

    while(true){
        int byteRead = in.read(buffer);
        if(byteRead == -1)
            break;
        for(int i = 0; i &lt; byteRead; i++){
            sb.append((char)buffer[i]);
        }
    }
    in.close();
    return sb.toString();
}
</code></pre>

<p>How can i do that?</p>

<p>Thanks!</p>
