Java Char Array to Byte Array charArrayToByteArray(final char[] message)

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

Description

Char array to byte array.

License

Open Source License

Parameter

Parameter Description
message the message

Return

the byte[]

Declaration

public static byte[] charArrayToByteArray(final char[] message) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w w w.j a  v  a  2s  .c  om
     * Char array to byte array.
     * 
     * @param message
     *            the message
     * @return the byte[]
     */
    public static byte[] charArrayToByteArray(final char[] message) {
        final byte[] payload = new byte[message.length];

        for (int i = 0; i < message.length; i++) {
            payload[i] = (byte) (message[i] & 0xFF);
        }

        return payload;
    }
}

Related

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