DexDataWriter extends BufferedOutputStream { public void writeEncodedUint(int valueType, int value) throws IOException { int index = 0; do { tempBuf[index++] = (byte)value; value >>>= 8; } while (value != 0); writeEncodedValueHeader(valueType, index-1); write(tempBuf, 0, index); } DexDataWriter(@Nonnull OutputStream output, int filePosition);  DexDataWriter(@Nonnull OutputStream output, int filePosition, int bufferSize); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); void writeLong(long value); static void writeInt(OutputStream out, int value); void writeInt(int value); void writeShort(int value); void writeUshort(int value); void writeUbyte(int value); static void writeUleb128(OutputStream out, int value); void writeUleb128(int value); static void writeSleb128(OutputStream out, int value); void writeSleb128(int value); void writeEncodedValueHeader(int valueType, int valueArg); void writeEncodedInt(int valueType, int value); void writeEncodedLong(int valueType, long value); void writeEncodedUint(int valueType, int value); void writeEncodedFloat(int valueType, float value); void writeEncodedDouble(int valueType, double value); void writeString(String string); void align(); int getPosition();  }
@Test public void testWriteEncodedUint() throws IOException { testWriteEncodedUintHelper(0x00, 0x00); testWriteEncodedUintHelper(0x01, 0x01); testWriteEncodedUintHelper(0x40, 0x40); testWriteEncodedUintHelper(0x7f, 0x7f); testWriteEncodedUintHelper(0x80, 0x80); testWriteEncodedUintHelper(0x81, 0x81); testWriteEncodedUintHelper(0xff, 0xff); testWriteEncodedUintHelper(0x100, 0x00, 0x01); testWriteEncodedUintHelper(0x180, 0x80, 0x01); testWriteEncodedUintHelper(0x8080, 0x80, 0x80); testWriteEncodedUintHelper(0x1234, 0x34, 0x12); testWriteEncodedUintHelper(0x1000, 0x00, 0x10); testWriteEncodedUintHelper(0x8000, 0x00, 0x80); testWriteEncodedUintHelper(0xff00, 0x00, 0xff); testWriteEncodedUintHelper(0xffff, 0xff, 0xff); testWriteEncodedUintHelper(0x10000, 0x00, 0x00, 0x01); testWriteEncodedUintHelper(0x1ffff, 0xff, 0xff, 0x01); testWriteEncodedUintHelper(0x80ffff, 0xff, 0xff, 0x80); testWriteEncodedUintHelper(0xffffff, 0xff, 0xff, 0xff); testWriteEncodedUintHelper(0x1000000, 0x00, 0x00, 0x00, 0x01); testWriteEncodedUintHelper(0x1020304, 0x04, 0x03, 0x02, 0x01); testWriteEncodedUintHelper(0x80000000, 0x00, 0x00, 0x00, 0x80); testWriteEncodedUintHelper(0x80ffffff, 0xff, 0xff, 0xff, 0x80); testWriteEncodedUintHelper(0xffffffff, 0xff, 0xff, 0xff, 0xff); }