Here you can find the source of charsToBytes(char[] in)
public static byte[] charsToBytes(char[] in)
//package com.java2s; /*//from w w w.j ava 2 s. c om * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. */ public class Main { /** * Note: only one-byte symbols are supported. */ public static byte[] charsToBytes(char[] in) { int size = in.length; byte[] out = new byte[size]; for (int i = 0; i < size; i++) { out[i] = (in[i] < 256) ? (byte) in[i] : 63 /* ? */; } return out; } }