@Test public void testReadUE7() throws Exception { byte[] data; data = new byte[] { 0x08 }; assertEquals((long)8, EndianUtils.readUE7(new ByteArrayInputStream(data))); data = new byte[] { (byte)0x84, 0x1e }; assertEquals((long)542, EndianUtils.readUE7(new ByteArrayInputStream(data))); data = new byte[] { (byte)0xac, (byte)0xbe, 0x17 }; assertEquals((long)728855, EndianUtils.readUE7(new ByteArrayInputStream(data))); }
public static long readUE7(InputStream stream) throws IOException { int i; long v = 0; while ((i = stream.read()) >= 0) { v = v << 7; if ((i & 128) == 128) { v += (i & 127); } else { v += i; break; } } if (i < 0) { throw new IOException("Buffer underun; expected one more byte"); } return v; }
EndianUtils { public static long readUE7(InputStream stream) throws IOException { int i; long v = 0; while ((i = stream.read()) >= 0) { v = v << 7; if ((i & 128) == 128) { v += (i & 127); } else { v += i; break; } } if (i < 0) { throw new IOException("Buffer underun; expected one more byte"); } return v; } }
EndianUtils { public static long readUE7(InputStream stream) throws IOException { int i; long v = 0; while ((i = stream.read()) >= 0) { v = v << 7; if ((i & 128) == 128) { v += (i & 127); } else { v += i; break; } } if (i < 0) { throw new IOException("Buffer underun; expected one more byte"); } return v; }  }
EndianUtils { public static long readUE7(InputStream stream) throws IOException { int i; long v = 0; while ((i = stream.read()) >= 0) { v = v << 7; if ((i & 128) == 128) { v += (i & 127); } else { v += i; break; } } if (i < 0) { throw new IOException("Buffer underun; expected one more byte"); } return v; }  static short readShortLE(InputStream stream); static short readShortBE(InputStream stream); static int readUShortLE(InputStream stream); static int readUShortBE(InputStream stream); static long readUIntLE(InputStream stream); static long readUIntBE(InputStream stream); static int readIntLE(InputStream stream); static int readIntBE(InputStream stream); static long readLongLE(InputStream stream); static long readLongBE(InputStream stream); static long readUE7(InputStream stream); static short getShortLE(byte[] data); static short getShortLE(byte[] data, int offset); static int getUShortLE(byte[] data); static int getUShortLE(byte[] data, int offset); static short getShortBE(byte[] data); static short getShortBE(byte[] data, int offset); static int getUShortBE(byte[] data); static int getUShortBE(byte[] data, int offset); static int getIntLE(byte[] data); static int getIntLE(byte[] data, int offset); static int getIntBE(byte[] data); static int getIntBE(byte[] data, int offset); static long getUIntLE(byte[] data); static long getUIntLE(byte[] data, int offset); static long getUIntBE(byte[] data); static long getUIntBE(byte[] data, int offset); static long getLongLE(byte[] data, int offset); static int ubyteToInt(byte b); static short getUByte(byte[] data, int offset); }
EndianUtils { public static long readUE7(InputStream stream) throws IOException { int i; long v = 0; while ((i = stream.read()) >= 0) { v = v << 7; if ((i & 128) == 128) { v += (i & 127); } else { v += i; break; } } if (i < 0) { throw new IOException("Buffer underun; expected one more byte"); } return v; }  static short readShortLE(InputStream stream); static short readShortBE(InputStream stream); static int readUShortLE(InputStream stream); static int readUShortBE(InputStream stream); static long readUIntLE(InputStream stream); static long readUIntBE(InputStream stream); static int readIntLE(InputStream stream); static int readIntBE(InputStream stream); static long readLongLE(InputStream stream); static long readLongBE(InputStream stream); static long readUE7(InputStream stream); static short getShortLE(byte[] data); static short getShortLE(byte[] data, int offset); static int getUShortLE(byte[] data); static int getUShortLE(byte[] data, int offset); static short getShortBE(byte[] data); static short getShortBE(byte[] data, int offset); static int getUShortBE(byte[] data); static int getUShortBE(byte[] data, int offset); static int getIntLE(byte[] data); static int getIntLE(byte[] data, int offset); static int getIntBE(byte[] data); static int getIntBE(byte[] data, int offset); static long getUIntLE(byte[] data); static long getUIntLE(byte[] data, int offset); static long getUIntBE(byte[] data); static long getUIntBE(byte[] data, int offset); static long getLongLE(byte[] data, int offset); static int ubyteToInt(byte b); static short getUByte(byte[] data, int offset);  }