这是我使用的代码:
class ResponseCodeCheck
{
public static void main (String args[]) throws Exception
{
URL url = new URL("http://www.amazon.co.jp/gp/seller/sell-your-stuff.html");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int code = connection.getResponseCode();
System.out.println("Response code of the object is "+code);
if (code==200)
{
System.out.println("OK");
}
}
}
当该 URL 工作正常时,它为 URL 提供了 404。有什么理由吗?