[b]控制台提示信息:[/b]
1.
[img]http://dl2.iteye.com/upload/attachment/0108/3011/25e9550f-a98a-3ade-a397-1f7adfcf1494.jpg[/img]
2.[img]http://dl2.iteye.com/upload/attachment/0108/3014/937da16d-31e1-37b8-bef8-e78c41356059.jpg[/img]
[b]在解析 xml格式的 InputStream,要先转字节码处理下再解析,否则可能会出现上面的错误。[/b]
==========================================================================
1.
[img]http://dl2.iteye.com/upload/attachment/0108/3011/25e9550f-a98a-3ade-a397-1f7adfcf1494.jpg[/img]
2.[img]http://dl2.iteye.com/upload/attachment/0108/3014/937da16d-31e1-37b8-bef8-e78c41356059.jpg[/img]
[b]在解析 xml格式的 InputStream,要先转字节码处理下再解析,否则可能会出现上面的错误。[/b]
public static String InputStreamTOString(InputStream in,String encoding) throws Exception{
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte[4096];
int count = -1;
while((count = in.read(data,0,2048)) != -1)
outStream.write(data, 0, count);
data = null;
return new String(outStream.toByteArray(),"ISO-8859-1");
}
==========================================================================
String xmlStr = this.InputStreamTOString(is, "utf-8");
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder db=dbf.newDocumentBuilder();
Document doc=db.parse(new InputSource(new StringReader(xmlStr)));