title: How to get a progress bar for a file upload with Apache HttpClient 4?
body: <p>I've got the following code for a file upload with Apache's HTTP-Client (org.apache.http.client):</p>
  
  <pre><code>  public static void main(String[] args) throws Exception
    {
      String fileName = "test.avi";
      File file = new File(fileName);
  
      String serverResponse = null;
      HttpParams params = new BasicHttpParams();
      params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, true);
      HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
      HttpClient client = new DefaultHttpClient(params);
      HttpPut put = new HttpPut("http://localhost:8080/" + fileName);
  
      FileEntity fileEntity = new FileEntity(file, "binary/octet-stream");
      put.setEntity(fileEntity);   
  
      HttpResponse response = client.execute(put);
      HttpEntity entity = response.getEntity();
      if (entity != null)
      {
        serverResponse = EntityUtils.toString(entity);
        System.out.println(serverResponse);
      }
    }
  </code></pre>
  
  <p>It work's quite well but now I want to have a progress bar which shows the progress of the file upload. How can this be made? I found a code snippet at <a href="https://stackoverflow.com/questions/254719/file-upload-with-java-with-progress-bar">File Upload with Java (with progress bar)</a> but it is designed for Apache HTTP Client 3 (org.apache.commons.httpclient) and the RequestEntity class does not exist in Apache HTTP Client 4. ;(</p>
  
  <p>Maybe someone of you has an approach?</p>
  
  <p>Many greetings</p>
  
  <p>Benny</p>