Java tutorial
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.charset.Charset; public class Main { public static String readMAString(ByteBuffer in) { int tmp = in.getInt(); byte[] dst = new byte[tmp]; in.get(dst); String ret = Charset.forName("UTF-8").decode(ByteBuffer.wrap(dst)).toString(); return ret; } }