您的位置:首页 > 其它

请求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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xml url
相关文章推荐