code: protected void copy(I_CmsRepositoryItem item, InputStream is, ServletOutputStream ostream) throws IOException {
  
          IOException exception = null;
          InputStream resourceInputStream = null;
  
          // Optimization: If the binary content has already been loaded, send
          // it directly
          if (!item.isCollection()) {
              byte[] buffer = item.getContent();
              if (buffer != null) {
                  ostream.write(buffer, 0, buffer.length);
                  return;
              }
              resourceInputStream = new ByteArrayInputStream(item.getContent());
          } else {
              resourceInputStream = is;
          }
  
          InputStream istream = new BufferedInputStream(resourceInputStream, m_input);
  
          // Copy the input stream to the output stream
          exception = copyRange(istream, ostream);
  
          // Clean up the input stream
          try {
              istream.close();
          } catch (Exception e) {
              if (LOG.isErrorEnabled()) {
                  LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_INPUT_STREAM_0), e);
              }
          }
  
          // 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 is the input stream to copy from
  @param ostream the output stream to write to
  
  @throws IOException if an input/output error occurs