服务器错误如下:
If an error occurred, a HTTP status code 503 (Service Unavailable)
will be returned. The MIME type will be set in accordance with the
format parameter that was specified in the request. The body of the
the returned page will contain the string "Error:" followed by a
string with further details. If XHTML was requested, this message will
appear somewhere in the document inside a element. If plain
text was requested, it will appear on the first line in the document.
所以,我用错误的参数发送请求 - >服务器返回错误503和带有描述问题的文本的页面。
我使用下面的java代码:
static BufferedReader getReader(String urlString) throws IOException {
HttpURLConnection connection;
BufferedReader reader = null;
URL url = new URL(urlString);
connection = (HttpURLConnection) url.openConnection();
reader = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
System.out.println(urlString);
return reader;
}当服务器返回503 - java抛出异常。但是,如何获取文本,该服务器返回?