Android Big Endian to Char Convert bigEndToChar(byte[] array, int start)

Here you can find the source of bigEndToChar(byte[] array, int start)

Description

Converts a byte array into char from big-endian format.

Declaration

public static char bigEndToChar(byte[] array, int start) 

Method Source Code

//package com.java2s;

public class Main {
    /**// w ww.ja v a 2  s  .  c o  m
     * Converts a byte array into char from big-endian format.
     * \param array The byte array to convert from.
     * \param start The starting point, int the array \a a, where the
     * conversion should start.
     * \returns The number after the conversion.
     **/
    public static char bigEndToChar(byte[] array, int start) {
        return (char) bigEndToShort(array, start);
    }

    /**
     * Converts a byte array into short from big-endian format.
     * \param array The byte array to convert from.
     * \param start The starting point, int the array \a a, where the
     * conversion should start.
     * \returns The number after the conversion.
     **/
    public static short bigEndToShort(byte[] array, int start) {
        return (short) ((array[start + 0] << 8) | (array[start + 1] & 0xFF));
    }
}