Here you can find the source of getMostSignificantByte(byte[] bytes, ByteOrder byteOrder)
Parameter | Description |
---|---|
bytes | a parameter |
byteOrder | a parameter |
private static byte getMostSignificantByte(byte[] bytes, ByteOrder byteOrder)
//package com.java2s; //License from project: Apache License import java.nio.ByteOrder; public class Main { /**// w w w. ja v a 2 s .com * Return the most significant byte in the provided byte array based on endianess. * * @param bytes * @param byteOrder * @return the most significant byte based on endianess. */ private static byte getMostSignificantByte(byte[] bytes, ByteOrder byteOrder) { byte mostSignificantByte = bytes[0]; if (byteOrder == ByteOrder.BIG_ENDIAN) { // do nothing // mostSignificantByte = bytes[0]; } else if (byteOrder == ByteOrder.LITTLE_ENDIAN) { mostSignificantByte = bytes[bytes.length - 1]; } else { throw new IllegalStateException("Unrecognized ByteOrder value[" + byteOrder + "]."); } return mostSignificantByte; } }