Java tutorial
//package com.java2s; public class Main { public static String toStringWithLength(byte[] b, int pos, int length) { StringBuilder str = new StringBuilder(); for (int i = 0; i < length; i++) { str.append((char) b[pos + i]); } String ret = str.toString(); return ret; } }