code: public void writeToStream(OutputStreamWithBuffer os)
      throws IOException
    {
      StreamImpl is = openReadImpl();
  
      try {
        byte []buffer = os.buffer();
        int offset = os.offset();
        int length = buffer.length;
  
        while (! os.isClosed()) {
          int sublen = length - offset;
  
          if (sublen <= 0) {
            buffer = os.nextBuffer(offset);
            offset = os.offset();
            sublen = length - offset;
          }
  
          sublen = is.read(buffer, offset, sublen);
  
          if (sublen <= 0) {
            os.offset(offset);
            return;
          }
  
          offset += sublen;
        }
      } finally {
        is.close();
      }
    }
docs: Utility to write the contents of this path to the destination stream.
  
  @param os destination stream.