read Little Endian Short - Java java.lang

Java examples for java.lang:int Format

Description

read Little Endian Short

Demo Code


//package com.java2s;
import java.io.DataInput;
import java.io.IOException;

public class Main {
    public static short readLittleEndianShort(DataInput in)
            throws IOException {
        int low = in.readUnsignedByte() & 0xff;
        int high = in.readUnsignedByte();
        return (short) (high << 8 | low);
    }/*from   www .  jav  a 2 s  . co  m*/
}

Related Tutorials