Here you can find the source of bytesToChar(byte[] bytes)
public static char[] bytesToChar(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { public static char[] bytesToChar(byte[] bytes) { char[] buffer = new char[bytes.length >> 1]; for (int i = 0; i < buffer.length; i++) { int bpos = i << 1; char c = (char) (((bytes[bpos] & 0x00FF) << 8) + (bytes[bpos + 1] & 0x00FF)); buffer[i] = c;/*from w ww. j a v a 2 s . c o m*/ } return buffer; } }