接收xml请求流并解析字符串的例子

 //接收请求发来的xml消息体,并返回xml字符串
public static String recieveData(HttpServletRequest request)
    {
       
        String inputLine = null;
        // 接收到的数据
        StringBuffer recieveData = new StringBuffer();
       
        BufferedReader in = null;
        try
        {
            in = new BufferedReader(new InputStreamReader(
                    request.getInputStream(), "UTF-8"));
            while ((inputLine = in.readLine()) != null)
            {
                recieveData.append(inputLine);
            }
        }
        catch (IOException e)
        {
        }
        finally
        {
           
            try
            {
                if (null != in)
                {
                    in.close();
                }
            }
            catch (IOException e)
            {
            }
           
        }
       
        return recieveData.toString();
    }

 

 

posted @ 2013-06-14 23:17  嗨,你的益达~~~  阅读(480)  评论(0编辑  收藏  举报