Here you can find the source of toByteArray(char[] charArray)
Parameter | Description |
---|---|
charArray | char[] |
public static byte[] toByteArray(char[] charArray)
//package com.java2s; public class Main { /**//from w ww . ja va2 s .co m * A utility method to convert from chars to bytes * @param charArray char[] * @return byte[] */ public static byte[] toByteArray(char[] charArray) { if (charArray == null) { return null; } byte[] result = new byte[charArray.length]; for (int i = 0; i < charArray.length; i++) { result[i] = (byte) charArray[i]; } return result; } }