Java tutorial
//package com.java2s; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; public class Main { private static String decode(Charset charset, byte[] b) { if (b == null) { return null; } final CharBuffer cb = charset.decode(ByteBuffer.wrap(b)); return new String(cb.array(), 0, cb.length()); } }