Java Byte Array to Char convertByteToCharArray(byte aByte)

Here you can find the source of convertByteToCharArray(byte aByte)

Description

convert Byte To Char Array

License

Open Source License

Declaration

static public char[] convertByteToCharArray(byte aByte) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2015 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://  ww  w  . ja  va2 s  .c o  m
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

public class Main {
    static public char[] convertByteToCharArray(byte aByte) {
        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;
    }
}

Related

  1. bytesToChar(byte[] bytes)
  2. bytesToChar(byte[] bytes)
  3. bytesToChar(byte[] bytes)
  4. convertByteToChar(byte input)
  5. convertByteToChar(byte[] source, int srclen)