Java Char Array Create toCharArray(byte[] byteArray)

Here you can find the source of toCharArray(byte[] byteArray)

Description

A utility method to convert from bytes to chars

License

Open Source License

Parameter

Parameter Description
byteArray byte[]

Return

char[]

Declaration

public static char[] toCharArray(byte[] byteArray) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   w  w w.ja va 2s  . c om
     * A utility method to convert from bytes to chars
     * @param byteArray byte[]
     * @return char[]
     */
    public static char[] toCharArray(byte[] byteArray) {
        if (byteArray == null) {
            return null;
        }

        char[] result = new char[byteArray.length];
        for (int i = 0; i < byteArray.length; i++) {
            result[i] = (char) byteArray[i];
        }

        return result;
    }
}

Related

  1. charArray(int arraySize)
  2. charArrayLiteral(CharSequence cs)
  3. toCharacterArray(String s)
  4. toCharArray(boolean[] array)
  5. toCharArray(byte[] barr)
  6. toCharArray(byte[] data)
  7. toCharArray(byte[] input)
  8. toCharArray(byte[] src)
  9. toCharArray(char... values)