Java Byte Array to Char convertByteToChar(byte[] source, int srclen)

Here you can find the source of convertByteToChar(byte[] source, int srclen)

Description

convert Byte To Char

License

LGPL

Declaration

public static char[] convertByteToChar(byte[] source, int srclen) 

Method Source Code

//package com.java2s;

public class Main {
    public static char[] convertByteToChar(byte[] source, int srclen) {
        if (source == null) {
            return null;
        }//from   w  ww.ja v  a 2s  . c  om

        int len = source.length;
        if (len > srclen) {
            len = srclen;
        }
        char[] destChar = new char[len];
        for (int i = 0; i < len; i++) {
            if (source[i] >= 0) {
                destChar[i] = (char) source[i];
            } else {
                destChar[i] = (char) (256 + source[i]);
            }
        }
        return destChar;
    }
}

Related

  1. bytesToChar(byte[] b)
  2. bytesToChar(byte[] bytes)
  3. bytesToChar(byte[] bytes)
  4. bytesToChar(byte[] bytes)
  5. convertByteToChar(byte input)
  6. convertByteToCharArray(byte aByte)