Java Utililty Methods Byte Array to Char

List of utility methods to do Byte Array to Char

Description

The list of methods to do Byte Array to Char are organized into topic(s).

Method

charbufferToChar(byte[] ioBuffer)
buffer To Char
return (char) ((ioBuffer[0] << 8) | (ioBuffer[1] & 255));
charbytesToChar(byte[] arr, int offset)
bytes To Char
return (char) ((arr[offset] << 8) | arr[offset + 1]);
charbytesToChar(byte[] arr, int pos)
Reads a character from a byte array.
checkBounds(arr, pos);
return (char) ((((short) arr[pos] << 8) & 0xFF00) | ((short) arr[pos + 1] & 0x00FF));
charbytesToChar(byte[] b)
bytes To Char
char c = (char) ((b[0] << 8) & 0xFF00L);
c |= (char) (b[1] & 0xFFL);
return c;
char[]bytesToChar(byte[] bytes)
bytes To Char
char[] buffer = new char[bytes.length >> 1];
for (int i = 0; i < buffer.length; i++) {
    int bpos = i << 1;
    char c = (char) (((bytes[bpos] & 0x00FF) << 8) + (bytes[bpos + 1] & 0x00FF));
    buffer[i] = c;
return buffer;
charbytesToChar(byte[] bytes)
bytes To Char
try {
    return (char) Short.parseShort(new String(bytes), 16);
} catch (RuntimeException e) {
return 0;
longbytesToChar(byte[] bytes)
bytes To Char
if (bytes == null || bytes.length == 0)
    return 0;
char val = 0;
for (int i = 0; i < 2 && i < bytes.length; i++) {
    val |= (char) (bytes[i] & 0xff) << (i * 8);
return val;
charconvertByteToChar(byte input)
convert Byte To Char
if ((int) input < 10) {
    return (char) (input + '0');
} else {
    return (char) ('A' + (int) input - 10);
char[]convertByteToChar(byte[] source, int srclen)
convert Byte To Char
if (source == null) {
    return null;
int len = source.length;
if (len > srclen) {
    len = srclen;
char[] destChar = new char[len];
...
char[]convertByteToCharArray(byte aByte)
convert Byte To Char Array
char charArray[] = new char[2];
int val = aByte;
if (val < 0)
    val += 256;
charArray[0] = Character.forDigit(val / 16, 16);
charArray[1] = Character.forDigit(val % 16, 16);
return charArray;