title: Exception on Mac only: Unexpected end of file from server
body: <p>I am downloading mp3 and image files using <strong>"org.apache.commons.io.FileUtils"</strong> in the following code successfully on windows 7: </p>
  
  <pre><code>FileUtils.copyURLToFile(new URL(urlString),myFile);
  </code></pre>
  
  <p>but on mac os x Yosemite version 10.10.2 (14C1514) I get this exception after few downloads:</p>
  
  <pre><code>   java.net.SocketException: Unexpected end of file from server
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:792)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:789)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1535)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
  </code></pre>
  
  <p>I have tried adding a timeout</p>
  
  <pre><code>FileUtils.copyURLToFile(new URL(url),myFile ,60000,60000);
  </code></pre>
  
  <p>or even using other methods</p>
  
  <pre><code>URLConnection conn = new URL(url).openConnection();
  InputStream is = conn.getInputStream();
  OutputStream outstream = new FileOutputStream(myFile);
  byte[] buffer = new byte[4096];
  int len;
  while ((len = is.read(buffer)) &gt; 0) {
      outstream.write(buffer, 0, len);
  }
  outstream.close();
  </code></pre>
  
  <p>Update:</p>
  
  <p>I tried to disable WiFi (to avoid any connectivity bugs as mentioned by @john) and used wired ethernet but still have the same error after few downloads, any help is appreciated.</p>