【发布时间】:2018-01-13 03:49:02
【问题描述】:
我使用类 HttpURLConnection ,但我对某些方法感到困惑
假设 HttpURLConnection 对象名称为“c”
删除 c.connect() 将导致连接成功,它会毫无问题地检索连接结果
c.getInputStream() 和 (InputStream) c.grtContent() 的输出是相同的,那么它们之间有什么区别
使用 HttpGet 会达到和 HttpURLConnection 一样的方法,那么这两种方法有什么区别
-
HttpURLConnection 在 URLConnection 上的额外好处是什么
c = (HttpURLConnection) (URL).openConnection(); c.connect(); //添加或删除结果相同,那么这个方法的用途是什么 InputStream 流= c.getInputStream(); InputStream stream2 = (InputStream) c.getContent(); //stream和stream2是一样的,那么getInputStream()和getContent()有什么区别
//==============================
HttpGet c=新的HttpGet(url); HttpResponse 响应 = c.execute(httpGet) InputStream stream3 = response.getEntity().getContent(); //stream3 也和 stream & stream2 一样;那么 HttpGet 和 HttpURLConnection 之间有何不同
【问题讨论】:
-
不要将您的问题放在代码 cmets 中。放到代码外可见的英文句子中。
-
完成@EJP ......
标签: java android networking httpurlconnection http-get