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