title: download zip file using java?
body: <p>I am downloading zip file from web server using Java but somehow I am loosing about 2kb in each file. I don't know why since same code works fine with other formats, e.g, text, mp3 and extra.
  any help is appreciated?
  here is my code.</p>
  
  <pre><code>public void download_zip_file(String save_to) {
      try {
          URLConnection conn = this.url.openConnection();
          conn.setDoOutput(true);
          conn.setDoInput(true);
          conn.setRequestProperty("content-type", "binary/data");
          InputStream in = conn.getInputStream();
          FileOutputStream out = new FileOutputStream(save_to + "tmp.zip");
  
          byte[] b = new byte[1024];
          int count;
  
          while ((count = in.read(b)) &gt; 0) {
              out.write(b, 0, count);
          }
          out.close();
          in.close();
  
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>