ULR url = new URL(urlString);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null)
{
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
1条答案
按热度按时间2nbm6dog1#
请参阅http状态代码:https://en.wikipedia.org/wiki/list_of_http_status_codes
应用程序应该处理所有http标准状态代码。