code: protected void copy(
          I_CmsRepositoryItem item,
          ServletOutputStream ostream,
          Iterator<CmsWebdavRange> ranges,
          String contentType) throws IOException {
  
          IOException exception = null;
  
          while ((exception == null) && (ranges.hasNext())) {
  
              InputStream resourceInputStream = new ByteArrayInputStream(item.getContent());
              InputStream istream = new BufferedInputStream(resourceInputStream, m_input);
  
              CmsWebdavRange currentRange = ranges.next();
  
              // Writing MIME header.
              ostream.println();
              ostream.println("--" + MIME_SEPARATION);
              if (contentType != null) {
                  ostream.println("Content-Type: " + contentType);
              }
              ostream.println(
                  "Content-Range: bytes "
                      + currentRange.getStart()
                      + "-"
                      + currentRange.getEnd()
                      + "/"
                      + currentRange.getLength());
              ostream.println();
  
              // Printing content
              exception = copyRange(istream, ostream, currentRange.getStart(), currentRange.getEnd());
  
              try {
                  istream.close();
              } catch (Exception e) {
                  if (LOG.isErrorEnabled()) {
                      LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_INPUT_STREAM_0), e);
                  }
              }
  
          }
  
          ostream.println();
          ostream.print("--" + MIME_SEPARATION + "--");
  
          // Rethrow any exception that has occurred
          if (exception != null) {
              throw exception;
          }
      }
docs: Copy the contents of the specified input stream to the specified
  output stream, and ensure that both streams are closed before returning
  (even in the face of an exception).<p>
  
  @param item the RepositoryItem
  @param ostream the output stream to write to
  @param ranges iterator of the ranges the client wants to retrieve
  @param contentType the content type of the resource
  
  @throws IOException if an input/output error occurs