Java examples for Internationalization:Big Endian Little Endian
Reads a Little Endian WORD value from a byte array.
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { byte[] data = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; int offset = 2; System.out.println(readWordLittleEndian(data, offset)); }/*from w w w.j av a2 s .co m*/ /** * Reads a Little Endian WORD value from a byte array. * * @param data The byte array from which the WORD value is read. * @param offset The index of the array element where WORD reading begins. * * @return The WORD value read from the array. */ public static int readWordLittleEndian(final byte[] data, final int offset) { return (data[offset + 1] & 0xFF) * 0x100 + (data[offset + 0] & 0xFF); } }