Here you can find the source of byteArrayToString(byte[] a)
public static String byteArrayToString(byte[] a)
//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; } }