Here you can find the source of bytetoChar(byte[] bytes)
public static char[] bytetoChar(byte[] bytes)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; public class Main { public final static String DEFAULT_CHARSET = "UTF-8"; public static char[] bytetoChar(byte[] bytes) { Charset cs = Charset.forName(DEFAULT_CHARSET); ByteBuffer bb = ByteBuffer.allocate(bytes.length); bb.put(bytes);//ww w. ja va2 s .c o m bb.flip(); CharBuffer cb = cs.decode(bb); return cb.array(); } }