首页 > 移动平台 > 详细

Android中通过get请求获取InputStream

时间:2015-02-26 16:10:53      阅读:289      评论:0      收藏:0      [点我收藏+]
	public InputStream getStream(String url) throws IllegalStateException, IOException {
		HttpResponse response = null;

		int timeoutConnection = 10000;
		int timeoutSocket = 10000;

		HttpParams httpParameters = new BasicHttpParams();
		HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
		HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
		DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
		HttpGet getRequest = new HttpGet(url);
		response = httpClient.execute(getRequest);
		if (response == null) {
			response = httpClient.execute(getRequest);
			LogUtils.LOGE("test", "resonse ------------ " + response);
		}
		long length = response.getEntity().getContentLength();
		if (length >= Constants.MAX_LENGTH) {
			return null;
		}
		return response.getEntity().getContent();
	}

 

Android中通过get请求获取InputStream

原文:http://www.cnblogs.com/wanghongwei/p/4301240.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!