Here you can find the source of toCharA(byte[] data)
public static char[] toCharA(byte[] data)
//package com.java2s; //License from project: Open Source License public class Main { public static char[] toCharA(byte[] data) { if (data == null || data.length % 2 != 0) return null; // ---------- char[] chrs = new char[data.length / 2]; for (int i = 0; i < chrs.length; i++) { chrs[i] = toChar(new byte[] { data[(i * 2)], data[(i * 2) + 1], }); }/*from w w w . j a va 2 s .c o m*/ return chrs; } public static char toChar(byte[] data) { if (data == null || data.length != 2) return 0x0; // ---------- return (char) ((0xff & data[0]) << 8 | (0xff & data[1]) << 0); } }