Java Char Create toCharA(byte[] data)

Here you can find the source of toCharA(byte[] data)

Description

to Char A

License

Open Source License

Declaration

public static char[] toCharA(byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static char[] toCharA(byte[] data) {
        if (data == null || data.length % 2 != 0)
            return null;
        // ----------
        char[] chrs = new char[data.length / 2];
        for (int i = 0; i < chrs.length; i++) {
            chrs[i] = toChar(new byte[] { data[(i * 2)], data[(i * 2) + 1], });
        }/*from  w  w  w .  j  a va  2  s  .c o  m*/
        return chrs;
    }

    public static char toChar(byte[] data) {
        if (data == null || data.length != 2)
            return 0x0;
        // ----------
        return (char) ((0xff & data[0]) << 8 | (0xff & data[1]) << 0);
    }
}

Related

  1. toChar(String delimiter)
  2. toChar(String parameter)
  3. toChar(String string)
  4. toChar(String string)
  5. toChar(String unicode)
  6. toCharacter(final String value)
  7. toCharacter(final String value)
  8. toCharacter(Object o)
  9. toCharacter(Object o)