code: protected IOException copyRange(InputStream istream, ServletOutputStream ostream, long start, long end) {
  
          if (LOG.isDebugEnabled()) {
              LOG.debug(Messages.get().getBundle().key(Messages.LOG_SERVE_BYTES_2, new Long(start), new Long(end)));
          }
  
          try {
              istream.skip(start);
          } catch (IOException e) {
              return e;
          }
  
          IOException exception = null;
          long bytesToRead = (end - start) + 1;
  
          byte[] buffer = new byte[m_input];
          int len = buffer.length;
          while ((bytesToRead > 0) && (len >= buffer.length)) {
              try {
                  len = istream.read(buffer);
                  if (bytesToRead >= len) {
                      ostream.write(buffer, 0, len);
                      bytesToRead -= len;
                  } else {
                      ostream.write(buffer, 0, (int)bytesToRead);
                      bytesToRead = 0;
                  }
              } catch (IOException e) {
                  exception = e;
                  len = -1;
              }
  
              if (len < buffer.length) {
                  break;
              }
          }
  
          return 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 istream the input stream to read from
  @param ostream the output stream to write to
  @param start the start of the range which will be copied
  @param end the end of the range which will be copied
  
  @return the exception which occurred during processing