Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
None
-
None
-
mac os x Yosemite version 10.10.2 (14C1514)
Description
http://stackoverflow.com/q/29853775/1356559
I am downloading 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 get this exception after few 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 have tried adding 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.close();
Update:
I tried to disable WiFi (to avoid any connectivity bugs) and used wired ethernet but still have the same error after few downloads, any help is appreciated.