Convert UTF8 byte array to String - Android java.lang

Android examples for java.lang:String UTF-8

Description

Convert UTF8 byte array to String

Demo Code

import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class Main{

    public static String newStringUtf8(byte[] strByte) {

        String result = null;/*from w  w w.j a  va  2s . c om*/
        try {
            result = new String(strByte, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

}

Related Tutorials