Java tutorial
//package com.java2s; public class Main { public static String byteArrayToString(byte[] value, int length) { int max = Math.min(length, value.length); StringBuilder stringBuilder = new StringBuilder(""); for (int i = 0; i < max; i++) { stringBuilder.append((char) value[i]); } return stringBuilder.toString(); } }