Java tutorial
//package com.java2s; public class Main { public static String getStr(byte[] b, int index) { int i; for (i = index; i < b.length; i++) { if (b[i] == 0) break; } if (i == index) return ""; byte[] str = new byte[i - index]; System.arraycopy(b, index, str, 0, i - index); return new String(str); } }