read Little Endian Int - Java java.lang

Java examples for java.lang:int Format

Description

read Little Endian Int

Demo Code


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

public class Main {
    public static int readLittleEndianInt(DataInput in) throws IOException {
        int bigEndian = 0;
        for (int shiftBy = 0; shiftBy < 32; shiftBy += 8) {
            bigEndian |= (in.readUnsignedByte() & 0xff) << shiftBy;
        }/*from w w  w  .  j  av  a  2s. c  o m*/
        return bigEndian;
    }
}

Related Tutorials