Mac only exception: Unexpected end of file from server

I am uploading MP3 and image files using "org.apache.commons.io.FileUtils" in the following code successfully on Windows 7:

FileUtils.copyURLToFile(new URL(urlString),myFile);

      

but on mac os x Yosemite version 10.10.2 (14C1514) I am getting this exception after multiple downloads:

   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)

      

I tried to add a timeout

FileUtils.copyURLToFile(new URL(url),myFile ,60000,60000);

      

or even using other methods

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)) > 0) {
    outstream.write(buffer, 0, len);
}
outstream.close();

      

Update:

I tried to disable WiFi (to avoid connection errors as @john mentioned) and used wired ethernet but still has the same error after multiple downloads, any help is appreciated.

+3


source to share


1 answer


It was ISP related and resolved the issue.



0


source







All Articles