@Test
  public void testByteArrayInputStreamWithOffset() throws Exception {
    byte[] bytes = new byte[] {0, 1, 2, 3, 4};
    InputStream input = new ByteArrayInputStream(bytes, 1, 4);
    try {
      byte[] bytesRead = StreamUtil.getBytesFromStream(input);
      byte[] expectedBytes = new byte[] {1, 2, 3, 4};
      assertTrue(Arrays.equals(expectedBytes, bytesRead));
    } finally {
      Closeables.close(input, true);
    }
  }
Verify that using an offset with ByteArrayInputStream still produces correct output.
fbcore/src/test/java/com/facebook/common/util/StreamUtilTest.java