Android examples for File Input Output:Byte Array Convert
Write short to little-endian byte array
//package com.book2s; import java.io.IOException; public class Main { /**/*from w w w.ja v a 2 s . c om*/ * Write short to little-endian byte array * @param value * @return * @throws IOException */ private static byte[] writeShort(short value) throws IOException { byte[] b = new byte[2]; b[0] = (byte) (value & 0x00FF); b[1] = (byte) ((value & 0xFF00) >> 8); return b; } }