Here you can find the source of toBytes(char[] chars)
public static byte[] toBytes(char[] chars)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] toBytes(char[] chars) { byte[] ret = new byte[chars.length]; for (int i = 0; i < chars.length; i++) { ret[i] = (byte) chars[i]; }/*from w ww .ja v a 2 s.co m*/ return ret; } }