帮我看看这是什么错误啊

ldhbq 2006-12-28 10:33:57
java.io.IOException: Server returned HTTP response code: 501 for URL: http://192.168.1.1/jc_all.html
小弟是做的一个本地下载文件的小程序.不知道什么原因老是这个错误.
URL url=new URL(str);
URLConnection urlConn=url.openConnection();
String line=System.getProperty("line.separator");
ta.append("Host: "+url.getHost());
ta.append(line);
ta.append("Port: "+url.getDefaultPort());
ta.append(line);
ta.append("ContentType: "+urlConn.getContentType());
ta.append(line);
ta.append("ContentLength: "+urlConn.getContentLength());
InputStream is=urlConn.getInputStream();


FileOutputStream fos=new FileOutputStream("1.html");
int data;
while((data=is.read())!=-1)
{
fos.write(data);
}

is.close();
fos.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
ContentType;ContentLength都获取不到.
望高手指点呀
...全文
206 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
numen_wlm 2006-12-28
  • 打赏
  • 举报
回复
可能是你浏览器的设置有问题,
Internet选项->高级->Http 1.1 设置
看里面的两个选项构选上没有?
ldhbq 2006-12-28
  • 打赏
  • 举报
回复
用127.0.0.1也没用.
ldhbq 2006-12-28
  • 打赏
  • 举报
回复
选上了怎么还是没用呀?
我用的是无线,网卡上的网.ip:192.168.1.200.网关和DNS是192.168.1.1
我输的是:http://192.168.1.1/例1-1(HelloWorld).html
Host: 192.168.1.1
Port: 80
ContentType: text/html
ContentLength: -1

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧