Android Array to String Convert byteArrayToString(byte[] a)

Here you can find the source of byteArrayToString(byte[] a)

Description

byte Array To String

Declaration

public static String byteArrayToString(byte[] a) 

Method Source Code

//package com.java2s;
import java.io.UnsupportedEncodingException;

public class Main {
    public static String byteArrayToString(byte[] a) {
        int i;//from  w  w  w .  j a v  a 2  s . c  om

        for (i = 0; i < a.length; ++i) {
            if (a[i] == 0) {
                break;
            }
        }

        try {
            return new String(a, 0, i, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        return null;
    }
}

Related

  1. toString(String[] iArray)
  2. toString(String s)
  3. toString(int[][] iArray)
  4. toString(long[][] iArray)
  5. toString(Object[] obj)
  6. bytetoString(byte[] b)
  7. hexToString(byte[] ids)
  8. toString(byte[] ba)
  9. toString(byte[] ba, int offset, int length)