Here you can find the source of toByteString(byte[] content, int len)
public static String toByteString(byte[] content, int len)
//package com.java2s; //License from project: Apache License public class Main { public static String toByteString(byte[] content, int len) { if (content == null || content.length == 0) { return ""; }// w w w . j a v a2s . c om if (len > content.length) { len = content.length; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i++) { int c = content[i]; c &= 0xFF; sb.append((char) c); } return sb.toString(); } public static String toByteString(byte[] content) { if (content == null) { return ""; } return toByteString(content, content.length); } }