WrappedByteArrayInputStream extends ByteArrayInputStream implements DuplicatableInputStream { public long length() { return buf.length; } WrappedByteArrayInputStream(byte[] buf); long length(); @Override InputStream duplicate();  }
@Test public void length() { byte[] buffer = new byte[35]; WrappedByteArrayInputStream stream = new WrappedByteArrayInputStream(buffer); assertEquals(35, stream.length()); }