我使用 aHttpURLConnection
连接到网站并接收ResponseCode=404 (HTTP_NOT_FOUND)
. 但是,我在浏览器 (IE) 中打开网站没有问题。
为什么会有差异,我能做些什么呢?
这是我的程序:
String responseMsg = "";
String cgsUrl = "http://localhost:9081/ntes/";
URL url = new URL(cgsUrl);
System.out.println("ouuuuuuu-->"+url.getContent());
InputStream in = url.openConnection().getInputStream();
StringBuffer respDataBuf = new StringBuffer();
respDataBuf.setLength(0);
int b = -1;
while((b = in.read()) != -1) {
respDataBuf.append((char)b);
}
responseMsg = respDataBuf.toString();