工作学习 问题总结 java httpurlconnection.getinputstream
来源:互联网 发布:淘宝二手ipad哪家靠谱 编辑:程序博客网 时间:2024/06/01 09:49
String c="ddddddddddddd";try { // surl="http://www.baidu.com"; URL url = new URL("http://33gfgfdfdfdfdf33.com"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(4500); conn.setReadTimeout(4500);// conn.connect(); conn.getInputStream(); c = new Integer(conn.getResponseCode()).toString(); String message = conn.getResponseMessage(); System.out.println("getResponseCode code ="+ c); System.out.println("getResponseMessage message ="+ message); if(!c.startsWith("2")){ throw new Exception("ResponseCode is not begin with 2,code="+c); } }catch(Exception ex){ System.out.println(c); ex.printStackTrace(); }
conn.getResponseCode())返回服务器响应状态码
conn.getinputstream() 会抛出此异常
dddddddddddddjava.net.UnknownHostException: 33gfgfdfdfdfdf33.comat java.net.AbstractPlainSocketImpl.connect(Unknown Source)at java.net.PlainSocketImpl.connect(Unknown Source)at java.net.SocksSocketImpl.connect(Unknown Source)at java.net.Socket.connect(Unknown Source)at sun.net.NetworkClient.doConnect(Unknown Source)at sun.net.www.http.HttpClient.openServer(Unknown Source)at sun.net.www.http.HttpClient.openServer(Unknown Source)可帮助文档是这样的,并没有说会抛出像上面这样的异常 ,这不坑人吗?
InputStream java.net.URLConnection.getInputStream() throws IOExceptiongetInputStreampublic InputStream getInputStream() throws IOExceptionReturns an input stream that reads from this open connection
- 工作学习 问题总结 java httpurlconnection.getinputstream
- android HttpURLConnection.getInputStream()问题
- HttpURLConnection.getInputStream java.io.FileNotFoundException
- android 4.0 HttpURLConnection. getInputStream() 为空的问题
- 工作学习问题总结:
- HttpURLConnection getInputStream异常的解决
- HttpURLConnection中getInputStream()报异常
- Java HttpURLConnection 总结
- 工作学习 问题总结 java 基础 关于arraylist.addall
- Android 4.0 HttpUrlConnection的getInputStream()方法总是返回空的问题
- android HttpURLConnection类的getInputStream方法返回中文显示乱码问题
- 如何解决在HttpURLConnection的getInputStream方法调用时出错的问题
- Java HttpURLConnection超时问题
- Java HttpURLConnection超时问题
- Java HttpURLConnection超时问题
- Java HttpURLConnection超时问题
- Java HttpURLConnection超时问题
- HttpURLConnection中connection.getInputStream()报异常FileNotFoundException
- 基于 Android NDK 的学习之旅-----JNI LOG 打印
- MySQL数据库之布尔类型、枚举类型和集合类型的应用场景详解
- .net 和MFC 比较
- 深入linux网络编程(三):异步阻塞IO —— epoll
- 基于 Android NDK 的学习之旅-----JNI 数据类型
- 工作学习 问题总结 java httpurlconnection.getinputstream
- VC++中Format函数详解
- 你需要知道的 16 个 Linux 服务器监控命令
- 基于 Android NDK 的学习之旅-----Java 调用C
- ftp服务的搭建之vsftpd的配置(解决外网无法访问的问题)
- Android性能测试工具Emmagee介绍
- C 判断是否是闰年
- linux系统下mysql中文乱码解决
- 使VC++中的srand rand 简单具备线程安全