📜  java 从连接中读取,即使 404 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:22.415000             🧑  作者: Mango

代码示例1
HttpURLConnection c = (HttpURLConnection)new URL("http://somesite.com").openConnection();
InputStream in = null;
if (c.getResponseCode() >= 400) {
   in = c.getErrorStream();
}  
else {
   in = c.getInputStream();
}