DexDataWriter extends BufferedOutputStream { @Override public void write(int b) throws IOException { filePosition++; super.write(b); } 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 testWriteByte() throws IOException { byte[] arr = new byte[257]; for (int i=0; i<256; i++) { arr[i] = (byte)i; writer.write(i); } arr[256] = (byte)0x80; writer.write(0x180); expectData(arr); }
@Test public void testWriteByteArray() throws IOException { byte[] arr = new byte[345]; random.nextBytes(arr); writer.write(arr); expectData(arr); }
@Test public void testWriteByteArrayWithLengthAndOffset() throws IOException { byte[] arr = new byte[345]; random.nextBytes(arr); writer.write(arr, 10, 300); expectData(Arrays.copyOfRange(arr, 10, 310)); }