android 网络编程

来源:互联网 发布:复共轭矩阵与厄米矩阵 编辑:程序博客网 时间:2024/04/30 14:45

xml,json解析就是将文本内容(file or string)解析为list对象集合

http下载,获得输入流,读取即可

上传参数:get方式,?参数1=值1&参数2=值2.附加在url后面

post方式,参数1=值1&参数2=值2,字符串输出流写入conn.getOutputStream().write(data);

上传xml,json等字符串。post 方式。设置内容类型,长度。

conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
conn.setRequestProperty("Content-Length", String.valueOf(data.length));

输出流写入string。conn.getOutputStream().write(data);



http上传文件,需要组拼麻烦实体数据。


socket通信,需要释放socket资源,关闭 输入输出流。

0 0
原创粉丝点击