Here you can find the source of convertCharToByte(char[] source, int srclen)
public static byte[] convertCharToByte(char[] source, int srclen)
//package com.java2s; public class Main { public static byte[] convertCharToByte(char[] source, int srclen) { if (source == null) { return null; }//from w w w . j a va 2 s . co m int len = source.length; if (len > srclen) { len = srclen; } byte[] dest = new byte[len]; for (int i = 0; i < len; i++) { dest[i] = (byte) source[i]; } return dest; } }