Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; public class Main { public static String readString(byte[] message, int start) { int pos = start; final int len = message.length; ByteArrayOutputStream os = new ByteArrayOutputStream(); while (pos < len) { if (message[pos] == '\0') { ++pos; break; } os.write(message[pos++]); } return os.toString(); } }