title: how to download a file in java?
body: <p>I've tried a few byte while loop methods and this method below: </p>
  
  <pre><code>try {
       URL dl = null;
       dl = new URL("http://ds-forums.com/kyle-tests/uploads/Screenshots.zip");
       ReadableByteChannel rbc = Channels.newChannel(dl.openStream());
       FileOutputStream fos = new FileOutputStream(fileName + "Screenshots.zip");
       fos.getChannel().transferFrom(rbc, 0, 1 &lt;&lt; 24);
       System.out.println(fos.getChannel().size());
       fos.close();
       rbc.close();
   } catch (Exception e) {
       e.printStackTrace();
   }
  </code></pre>
  
  <p>}  </p>
  
  <p>But the methods just aren't very efficient/fast. I found out about the apache Utils and I'm using</p>
  
  <pre><code> IOUtils.copy(new URL("http://ds-forums.com/kyle-tests/uploads/Screenshots.zip").openStream(), new FileOutputStream(System.getProperty("user.home").replace("\\", "/") + "/Desktop/Screenshots.zip"));
  </code></pre>
  
  <p>but is that the best method? I'm so confused right now which method is best for downloading a zipped file 26mb.  (The file above is only 1mb I'm testing methods)</p>
  
  <p>I'm asking just to see if someone else ever ran into this problem and maybe they could help me.  Thanks.</p>