Here you can find the source of toByteArray(char[] chars)
Parameter | Description |
---|---|
chars | the char array |
public static byte[] toByteArray(char[] chars)
//package com.java2s; public class Main { /**//ww w. j a va2s. c o m * Convert the given char array into a byte array. * * @param chars the char array * @return the converted array */ public static byte[] toByteArray(char[] chars) { byte[] result = new byte[chars.length]; for (int i = chars.length - 1; i >= 0; i--) { result[i] = (byte) chars[i]; } return result; } }