请求url并返回信息以xml形式显示

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

本文出自 “Lovely喵儿” 博客,谢绝转载!

你可能感兴趣的:(xml,url)