java503错误解决_java的。远程服务器返回503错误页面,其中包含一些文本。如何获取此文本?...

服务器错误如下:

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抛出异常。但是,如何获取文本,该服务器返回?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值