java.io.IOException: Server returned HTTP response code: 416 for URL: http://192.168.18.27:8080/15.jpg
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at com.itcast.downloader.download$downloadTH.run(download.java:47)
huc.setRequestProperty("Range", "bytes = "+start+"-"+end);
"bytes = "+start+"-"+end语句内不能带空格!!
HTTP response code: 416是由于读取文件时设置的Range有误造成的,具体的说就是下面这行代码有误:
httpConnection.setRequestProperty("RANGE", "bytes=1024-");
这个RANGE显然不能超出文件的size