Here you can find the source of convertCharsToBytes(char[] chars)
public static byte[] convertCharsToBytes(char[] chars)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] convertCharsToBytes(char[] chars) { byte[] result = new byte[chars.length * 2]; for (int i = 0; i < chars.length; ++i) { result[2 * i] = (byte) (chars[i] / 256); result[2 * i + 1] = (byte) (chars[i] % 256); }/*www. j a v a 2s . co m*/ return result; } }