Android examples for java.lang:Character
Create a byte array from a char array
public class Main{ /**//w w w. ja v a 2 s.c om * Create a byte array from a char array * * @param chars * the char array * @return a byte array */ public static byte[] charArrayToByteArray(char[] chars) { byte[] bytes = new byte[chars.length]; for (int i = 0; i < chars.length; i++) { bytes[i] = (byte) chars[i]; } return bytes; } }