private long readUInt(InputStream is) throws IOException { try { return EndianUtils.readUIntLE(is); } catch (EndianUtils.BufferUnderrunException e) { throw new IOException(e); } }
@Test public void testReadUIntLE() throws Exception { byte[] data = new byte[] {(byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00 }; assertEquals((long) 8, EndianUtils.readUIntLE(new ByteArrayInputStream(data))); data = new byte[] {(byte)0xF0, (byte)0xFF, (byte)0xFF, (byte)0xFF }; assertEquals(4294967280L, EndianUtils.readUIntLE(new ByteArrayInputStream(data))); data = new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF }; try { EndianUtils.readUIntLE(new ByteArrayInputStream(data)); fail("Should have thrown exception"); } catch (EndianUtils.BufferUnderrunException e) { } }
@Test public void testReadUIntBE() throws Exception { byte[] data = new byte[] {(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x08 }; assertEquals((long) 8, EndianUtils.readUIntBE(new ByteArrayInputStream(data))); data = new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xF0 }; assertEquals(4294967280L, EndianUtils.readUIntBE(new ByteArrayInputStream(data))); data = new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF }; try { EndianUtils.readUIntLE(new ByteArrayInputStream(data)); fail("Should have thrown exception"); } catch (EndianUtils.BufferUnderrunException e) { } } }
private long readUInt(InputStream is) throws IOException { try { return EndianUtils.readUIntLE(is); } catch (EndianUtils.BufferUnderrunException e) { throw new IOException(e); } }
private long readUInt(InputStream is) throws IOException { try { return EndianUtils.readUIntLE(is); } catch (EndianUtils.BufferUnderrunException e) { throw new IOException(e); } }