@Override
  public void write(OutputStream os) throws IOException {
    IOUtils.skipFully(is, offset);
    long bytes = 0L;
    if (len == -1) {
      // Use the configured buffer size instead of hardcoding to 4k
      bytes = FSOperations.copyBytes(is, os);
    } else {
      bytes = FSOperations.copyBytes(is, os, len);
    }
    // Update metrics.
    HttpFSServerMetrics metrics = HttpFSServerWebApp.get().getMetrics();
    if (metrics != null) {
      metrics.incrBytesRead(bytes);
    }
  }
@Test
  public void test() throws Exception {
    InputStream is = new ByteArrayInputStream("abc".getBytes());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStreamEntity i = new InputStreamEntity(is);
    i.write(baos);
    baos.close();
    assertEquals(new String(baos.toByteArray()), "abc");

    is = new ByteArrayInputStream("abc".getBytes());
    baos = new ByteArrayOutputStream();
    i = new InputStreamEntity(is, 1, 1);
    i.write(baos);
    baos.close();
    assertEquals(baos.toByteArray()[0], 'b');
  }