帮我看看这是什么错误啊
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都获取不到.
望高手指点呀