convert Byte Array To String in UTF-8 - Android java.lang

Android examples for java.lang:Byte Array

Description

convert Byte Array To String in UTF-8

Demo Code

import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class Main{

    public static String convertByteArrayToString(byte[] data) {
        try {//w  w w  .j  ava 2 s.co  m
            return new String(data, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        return null;
    }

}

Related Tutorials