public static byte[] readBinaryCodedLengthBytes(byte[] data, int index) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(data[index]);

        byte[] buffer = null;
        int value = data[index] & 0xFF;
        if (value == 251) {
            buffer = new byte[0];
        }
        if (value == 252) {
            buffer = new byte[2];
        }
        if (value == 253) {
            buffer = new byte[3];
        }
        if (value == 254) {
            buffer = new byte[8];
        }
        if (buffer != null) {
            System.arraycopy(data, index + 1, buffer, 0, buffer.length);
            out.write(buffer);
        }

        return out.toByteArray();
    }
@Test
	public void testReadBinaryCodedLengthBytes() throws Exception {
		Assert.assertArrayEquals(new byte[] {95},
			ByteHelper.readBinaryCodedLengthBytes(new byte[] {94, 95, 96}, 1));
		Assert.assertArrayEquals(new byte[] {-5},
			ByteHelper.readBinaryCodedLengthBytes(new byte[] {-4, -5, -6}, 1));
		Assert.assertArrayEquals(new byte[] {-4, -6, -7},
			ByteHelper.readBinaryCodedLengthBytes(new byte[] {-6, -4, -6, -7, -8}, 1));
		Assert.assertArrayEquals(new byte[] {-3, -4, -5, -6},
			ByteHelper.readBinaryCodedLengthBytes(new byte[] {-2, -3, -4, -5, -6}, 1));
		Assert.assertArrayEquals(new byte[] {-2, -3, -4, -5, -6, -7, -8, -9, -10},
			ByteHelper.readBinaryCodedLengthBytes(new byte[] {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10}, 1));
	}