android解析httpresponce内容
16lz
2022-06-09
android的app没有不联网的基本上现在,经常会有与服务器的交互这个时候,会遇到很多解析服务器返回的数据这个简单的函数就是干这个的
1 static public String Change(HttpResponse httpResponce) { 2 String result = null; 3 try { 4 BufferedReader bufferedReader = new BufferedReader( 5 new InputStreamReader(httpResponce.getEntity().getContent())); 6 StringBuffer stringBuffer = new StringBuffer(""); 7 // 获取本系统的行分割线 8 String NL = System.getProperty("line.separator"); 9 // 把http响应的输入流数据按行读取到StringBuffer中10 String line = "";11 while ((line = bufferedReader.readLine()) != null) {12 stringBuffer.append(line + NL);13 }14 result = stringBuffer.toString();15 } catch (IllegalStateException e) {16 // TODO Auto-generated catch block17 e.printStackTrace();18 } catch (IOException e) {19 // TODO Auto-generated catch block20 e.printStackTrace();21 }22 System.out.println("the result is " + result);23 return result;24 }
更多相关文章
- 初学Android,数据存储之File存储(四十二)
- Android(安卓)Camera调用流程
- android 基于ffmpeg将视频采集的nv21转h264格式数据
- Android中通过按键旋转屏幕
- 深入理解数据结构
- android findViewById
- mybatisplus的坑 insert标签insert into select无参数问题的解决
- 箭头函数的基础使用
- python起点网月票榜字体反爬案例