Java Char Array to Byte Array charArrayToByteArray(char[] value)

Here you can find the source of charArrayToByteArray(char[] value)

Description

convert char array value to byte array value

License

Apache License

Parameter

Parameter Description
value char array value

Return

byte array value

Declaration

public static byte[] charArrayToByteArray(char[] value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  w  ww .j  a  va2  s .  co  m
     * convert char array value to byte array value
     * 
     * @param value char array value
     * @return byte array value
     */
    public static byte[] charArrayToByteArray(char[] value) {
        byte[] result = new byte[value.length];
        for (int i = 0; i < value.length; i++)
            result[i] = (byte) value[i];
        return result;
    }
}

Related

  1. char2byte(char[] chars, int offset, int len, byte[] result, int roffset)
  2. charArrayToByteArray(char charBuf[])
  3. charArrayToByteArray(char[] c)
  4. charArrayToByteArray(final char[] message)
  5. charArrayToBytes(char[] chars)
  6. chars2Bytes(char[] chars)
  7. chars2Bytes(char[] chars)