生成XML出错

Kifile Kifile 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在Struts2框架下,使用dom4j生成XML文件,但是,有一个文件生成时提示undefined,想请教一下原因。

我是在InputStream中放入我想要输出的字符流,,代码如下

xml=new ByteArrayInputStream(dom.asXML().getBytes());

try {
InputStreamReader r = new InputStreamReader(xml,"UTF-8");
StringBuffer sb=new StringBuffer();
int b;
while((b=r.read())!=-1 ){
if((char)b=='\n'){
sb.append("回车");
}else{
sb.append((char)b);
}
}
System.out.println(sb.toString());
} catch (Exception e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}


xml=new ByteArrayInputStream(dom.asXML().getBytes());


首先我在命令行上打印输出流,满足我的要求,然后当我直接查看网页上的输出时,发现最后两个标签间多了一个undefined,希望大家帮忙解释,解决一下


...全文
评论 4
收藏 已收藏
分享
返回顶部
Kifile
Web 开发 81,108 成员 341,721 内容