title: download file with multiple connections
body: <p>Hi i want to download <em>a file</em> with <em>multi java.net.Socket 's</em>.
  I can get file with basic GET request :</p>
  
  <pre><code>Socket socket = new Socket(serverName, 80);
  DataOutputStream bw = new DataOutputStream(socket.getOutputStream());
  bw.writeBytes("GET " + requestFileName + " HTTP/1.1\r\n");
  bw.writeBytes("Host: " + serverName + ":80\r\n\r\n");
  bw.flush();
  
  DataInputStream in = new DataInputStream(socket.getInputStream());
  
  OutputStream dos = new FileOutputStream(indexFileName);
  byte[] buffer = new byte[2048];
  while ((count = in.read(buffer)) != -1) {
      dos.write(buffer, 0, count);
      dos.flush();
  }
  dos.close();
  socket.close();
  </code></pre>
  
  <p>This works perfectly but not sufficient because i wish to use multi sockets.
  I can get Header with requesting HEAD so i can get only <em>Content-Length</em>
  Now my plan is create threads with using this code. For instance if i want to download a file with 3 threads ; i will divide Content-Length by 3 and will download with 3 three thread. (0-99) + (100-199) + (200-299) = 300 for 300 bytes
  then i will join parts but i could not find a way to parallel file download. Do i just need to change below part ?</p>
  
  <pre><code>while ((count = in.read(buffer)) != -1) {
      dos.write(buffer, 0, count);
      dos.flush();
  }
  </code></pre>
  
  <p>or try to request from server with range of file size ?
  For example </p>
  
  <ul>
  <li>GET 0-99 bytes of a.dat and put it into a.dat.part1</li>
  <li>GET 100-199 bytes of a.dat and put it into a.dat.part1 </li>
  <li>GET 200-299    bytes of a.dat and put it into a.dat.part1</li>
  </ul>