Converts a byte array to a String - Android java.lang

Android examples for java.lang:Byte Array

Description

Converts a byte array to a String

Demo Code

import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;

public class Main{

    /**/*from w  w w .jav a  2s.c o  m*/
     * Converts a byte array to a String
     * @param data      byte[] of data to encode
     * @return          encoded data
     */
    public static String bin2String(byte[] data) {
        String encoded_data = null;

        try {
            encoded_data = new String(data, ENCODER);
        } catch (UnsupportedEncodingException e) {
            Log.d("debug", e.toString());
        }

        return encoded_data;
    }

}

Related Tutorials