title: Java - Download zip file from url
body: <p>I have a problem with downloading a zip file from an url.
  It works well with firefox but with my app I have a 404.</p>
  
  <p>Here is my code</p>
  
  <pre><code>URL url = new URL(reportInfo.getURI().toString());
  HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
  
  // Check for errors
  int responseCode = con.getResponseCode();
  InputStream inputStream;
  if (responseCode == HttpURLConnection.HTTP_OK) {
      inputStream = con.getInputStream();
  } else {
      inputStream = con.getErrorStream();
  }
  
  OutputStream output = new FileOutputStream("test.zip");
  
  // Process the response
  BufferedReader reader;
  String line = null;
  reader = new BufferedReader(new InputStreamReader(inputStream));
  while ((line = reader.readLine()) != null) {
      output.write(line.getBytes());
  }
  
  output.close();
  inputStream.close();
  </code></pre>
  
  <p>Any idea ?</p>