(一)HttpURLConnection之Get请求(解决乱码)
来源:互联网 发布:科比0506赛季每场数据 编辑:程序博客网 时间:2024/06/11 16:24
public static String executeHttpGet() {String result = null;URL url = null;HttpURLConnection connection = null;InputStreamReader in = null;try {url = new URL("http://api.showji.com/Locating/www.show.ji.c.o.m.aspx?m=18766581234&output=json&callback=querycallback×tamp=1409020493933");connection = (HttpURLConnection) url.openConnection();connection.setDoOutput(true);connection.setRequestMethod("GET");connection.setRequestProperty("Content-type", "text/html");connection.setRequestProperty("Accept-Charset", "UTF-8");connection.setRequestProperty("contentType", "UTF-8");if(connection.getResponseCode()== HttpURLConnection.HTTP_OK){in = new InputStreamReader(connection.getInputStream(),"UTF-8");BufferedReader bufferedReader = new BufferedReader(in);StringBuffer stringBuffer = new StringBuffer();String line = null;while ((line = bufferedReader.readLine()) != null) {stringBuffer.append(line);}result = stringBuffer.toString();}else{result="网络连接错误";}} catch (Exception e) {// TODO: handle exceptione.printStackTrace();} finally {if (connection != null) {connection.disconnect();}if (in != null) {try {in.close();} catch (Exception e2) {// TODO: handle exceptione2.printStackTrace();}}}return result;}
0 0
- (一)HttpURLConnection之Get请求(解决乱码)
- HttpURLConnection (get请求)
- HttpURLConnection之GET请求
- get请求,中文乱码解决 之 百度如何正确获取中文请求参数(我猜测)
- JavaHttp GET POST 请求(HttpURLConnection)
- Android网络请求之HttpURLConnection小结(一)
- android 中访问网络介绍 一 (基于httpurlconnection 的中get请求)
- get请求乱码解决详解
- get请求参数乱码解决
- Android 网络请求(一)HttpURLConnection+OkHttp
- Android开发之网络请求通信专题(一):基于HttpURLConnection的请求通信
- Java开发GET/POST请求中文乱码、JSP页面中文乱码(100%能解决)
- java发送post和get请求(1)---HttpURLConnection方式
- HttpURLConnection请求数据(GET)并用JSON解析数据(二)
- 使用HttpURLConnection采用get方式请求数据-----乱码问题
- Java Web乱码分析及解决方案(一)——GET请求乱码
- HttpUrlconnection get请求数据
- HttpURLConnection 的get请求
- 数字信号处理中各种频率关系
- uva 11983 - Weird Advertisement(线段树)
- 学习FPGA的网站推荐
- spring3.0事务管理配置
- Android ListView优化总结
- (一)HttpURLConnection之Get请求(解决乱码)
- Android 解决ListView的itemClick和里面的Button点击有冲突问题
- 【转发】神经网络和用户行为–程序员也必须要了解神经网络
- secureCRT中的中文显示乱码和设置打印颜色处理
- Sort List
- 敏捷开发方法XP的12个最佳实践
- dwz多文件上传
- Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法
- IP 验证,IP转Long,Long转IP