Create a char array from a byte array - Android java.lang

Android examples for java.lang:Character

Description

Create a char array from a byte array

Demo Code

public class Main{

    /**/*from www.  ja va2  s.c om*/
     * Create a char array from a byte array
     * 
     * @param bytes
     *            the byte array
     * @return a char array
     */
    public static char[] byteArrayToCharArray(byte[] bytes) {
        char[] result = new char[bytes.length];
        for (int i = 0; i < bytes.length; i++) {
            result[i] = (char) bytes[i];
        }
        return result;
    }

}

Related Tutorials