Here you can find the source of bytesToChar(byte[] bytes)
public static long bytesToChar(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { public static long bytesToChar(byte[] bytes) { if (bytes == null || bytes.length == 0) return 0; char val = 0; for (int i = 0; i < 2 && i < bytes.length; i++) { val |= (char) (bytes[i] & 0xff) << (i * 8); }//from w ww . j a v a 2 s .com return val; } }