Java examples for java.nio:ByteBuffer Read
Read Unsigned Int from InputStream via ByteBuffer
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; public class Main { private static ByteBuffer bb = ByteBuffer.allocate(8); private static byte[] tempBuffer = new byte[8]; private static byte[] padder = { 0, 0, 0, 0, 0, 0, 0, 0 }; public static long ReadUnsignedInt(InputStream is) throws IOException { bb.position(0);//from ww w . ja v a 2 s . co m is.read(tempBuffer, 0, 4); bb.put(tempBuffer, 0, 4); bb.put(padder, 0, 4); return bb.getLong(0); } }