请求url并返回信息以xml形式显示
2012-05-10 12:15
302 查看
URL url = new URL("http://");
HttpURLConnection httpConn = (HttpURLConnection) url
.openConnection();
httpConn.setDoOutput(true);
httpConn.setRequestMethod("POST");
httpConn.getOutputStream().flush();
httpConn.getOutputStream().close();
int code = httpConn.getResponseCode();
BufferedReader in = null;
if (code == HttpURLConnection.HTTP_OK) {
in = new BufferedReader(new InputStreamReader(
httpConn.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
date.append(new String(line.getBytes(), "utf-8"));
}
}
httpConn.disconnect();
http://www.cnblogs.com/lzhdevil/archive/2012/05/10/2494079.html
HttpURLConnection httpConn = (HttpURLConnection) url
.openConnection();
httpConn.setDoOutput(true);
httpConn.setRequestMethod("POST");
httpConn.getOutputStream().flush();
httpConn.getOutputStream().close();
int code = httpConn.getResponseCode();
BufferedReader in = null;
if (code == HttpURLConnection.HTTP_OK) {
in = new BufferedReader(new InputStreamReader(
httpConn.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
date.append(new String(line.getBytes(), "utf-8"));
}
}
httpConn.disconnect();
http://www.cnblogs.com/lzhdevil/archive/2012/05/10/2494079.html
相关文章推荐
- 给retrofit 的 添加okhttp的拦截器,可以让她显示 请求和返回的信息 ,便于查找错误
- Java实现Flash请求的二进制流图片保存并返回XML信息包含图片访问地址
- 接受xml字符串+以流的形式返回信息
- java调用webservice天气预报(SOAP请求的方式获取天气信息并解析返回的XML)
- java调用webservice天气预报(SOAP请求的方式获取天气信息并解析返回的XML)
- 通过请求不同的url返回Json对象并在前端显示的解决方法
- 根据URL请求 返回XML字符串
- java调用webservice天气预报(SOAP请求的方式获取天气信息并解析返回的XML)
- 用一个WEB服务或普通站点 实现这样一个效果?以URL请求,返回一个XML文档
- 初涉Ajax,以post或get方法发送数据,以json或xml形式接收服务器返回的请求
- 在Java中使用HttpURLConnection发送http客户端请求、服务器端返回信息、接受服务器端的信息
- 利用HttpWebRequest请求url路径返回json结果对象
- 使用HttpUrlConnection+Handler几秒钟更换一次信息,使用HttpClient+AsyncTask请求列表信息
- 获取客户端上次请求的url的有关信息
- struts.xml配置和url请求解释
- 请求一个url 获得返回结果(doPost doGet方式)
- VPOS MAS-CNP接口——建立https连接发送请求并接收返回的XML数据流
- jquery ajax请求方式与提示用户正在处理请稍等,等待数据返回时loading的显示
- Ajax多次请求同一个URL返回相同值问题
- HttpClient 发送Post,Get请求例子(包含设置请求头信息和获取返回头信息)