### Question:
RunLengthCodec implements IByteArrayStreamDecoder { public void decode (@Nullable final byte [] aEncodedBuffer, @Nonnegative final int nOfs, @Nonnegative final int nLen, @Nonnull @WillNotClose final OutputStream aOS) { if (aEncodedBuffer == null || nLen == 0) return; try (final NonBlockingByteArrayInputStream aBAIS = new NonBlockingByteArrayInputStream (aEncodedBuffer, nOfs, nLen)) { int nDupAmount; final byte [] aReadBuffer = new byte [128]; while ((nDupAmount = aBAIS.read ()) != -1 && nDupAmount != RUN_LENGTH_EOD) { if (nDupAmount <= 0x7f) { int nAmountToCopy = nDupAmount; while (nAmountToCopy > 0) { final int nCompressedRead = aBAIS.read (aReadBuffer, 0, nAmountToCopy); if (nCompressedRead < 0) throw new DecodeException ("Unexpected EOF in RunLengthCodec - " + nAmountToCopy + " elements left"); aOS.write (aReadBuffer, 0, nCompressedRead); nAmountToCopy -= nCompressedRead; } } else { final int aDupByte = aBAIS.read (); if (aDupByte == -1) throw new DecodeException ("Unexpected EOF in RunLengthCodec"); for (int i = 0; i < 257 - nDupAmount; i++) aOS.write (aDupByte); } } } catch (final IOException ex) { throw new DecodeException ("Failed to decode RunLength", ex); } } RunLengthCodec(); void decode(@Nullable final byte [] aEncodedBuffer,
                      @Nonnegative final int nOfs,
                      @Nonnegative final int nLen,
                      @Nonnull @WillNotClose final OutputStream aOS);  }### Answer:
@Test public void testDecode () { final RunLengthCodec c = new RunLengthCodec (); assertEquals ("WWWWWWWWWWWWTFF", c.getDecodedAsString (new byte [] { (byte) (257 - 12), 'W', 0x03, 'T', 'F', 'F' }, CHARSET)); assertEquals ("WWWWWWWWWWTFF", c.getDecodedAsString (new byte [] { (byte) (257 - 10), 'W', 0x03, 'T', 'F', 'F', (byte) 0x80 }, CHARSET)); }