public synchronized void doGet(Path path, final java.io.File file, ProgressListener listener)
      throws IOException, NotFoundException, com.ettrema.httpclient.HttpException,
          CancelledException, NotAuthorizedException, BadRequestException, ConflictException {
    LogUtils.trace(log, "doGet", path);
    if (fileSyncer != null) {
      fileSyncer.download(this, path, file, listener);
    } else {
      String url = this.buildEncodedUrl(path);
      transferService.get(
          url,
          new StreamReceiver() {

            @Override
            public void receive(InputStream in) throws IOException {
              OutputStream out = null;
              BufferedOutputStream bout = null;
              try {
                out = FileUtils.openOutputStream(file);
                bout = new BufferedOutputStream(out);
                IOUtils.copy(in, bout);
                bout.flush();
              } finally {
                IOUtils.closeQuietly(bout);
                IOUtils.closeQuietly(out);
              }
            }
          },
          null,
          listener);
    }
  }
  /**
   * Retrieve the bytes at the specified path.
   *
   * @param path - encoded but not fully qualified. Must NOT be slash prefixed as it will be
   *     appended to the host's url
   * @return
   * @throws com.ettrema.httpclient.HttpException
   */
  public synchronized byte[] get(String path)
      throws com.ettrema.httpclient.HttpException, NotAuthorizedException, BadRequestException,
          ConflictException, NotFoundException {
    String url = this.encodedUrl() + path;
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
      transferService.get(
          url,
          new StreamReceiver() {

            @Override
            public void receive(InputStream in) {
              try {
                IOUtils.copy(in, out);
              } catch (IOException ex) {
                throw new RuntimeException(ex);
              }
            }
          },
          null,
          null);
    } catch (CancelledException ex) {
      throw new RuntimeException("Should never happen because no progress listener is set", ex);
    }
    return out.toByteArray();
  }
 /**
  * @param url - fully qualified and encoded URL
  * @param receiver
  * @param rangeList - if null does a normal GET request
  * @throws com.ettrema.httpclient.HttpException
  * @throws com.ettrema.httpclient.Utils.CancelledException
  */
 public synchronized void doGet(
     String url, StreamReceiver receiver, List<Range> rangeList, ProgressListener listener)
     throws com.ettrema.httpclient.HttpException, Utils.CancelledException, NotAuthorizedException,
         BadRequestException, ConflictException, NotFoundException {
   transferService.get(url, receiver, rangeList, listener);
 }