获取xml信息并转为string

前端之家收集整理的这篇文章主要介绍了获取xml信息并转为string前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { ServletInputStream ToUserName = request.getInputStream(); final int BUFFER_SIZE = 8 * 1024; byte[] buffer = new byte[BUFFER_SIZE]; int length = 0; ByteArrayOutputStream baos = new ByteArrayOutputStream(); do { length = ToUserName.read(buffer); if (length > 0) { baos.write(buffer,length); } } while (length * 2 == BUFFER_SIZE); byte[] ba = baos.toByteArray(); String body = new String(ba,"utf-8"); System.out.println("body::::" + body); }

猜你在找的XML相关文章