java.net.MalformedURLException: no protocol解决方法
(2013-09-18 18:29:06)
标签:
xmlxpathno_protocolandroid乱码 |
分类: xml |
原帖:http://www.joyphper.net/article/201204/146.html
好久没写博客了
出问题的代码如下:
- String
xml ="<?xml version="1.0"?>.......";//此处xml是通过接口获取到的xml字符串 -
DocumentBuilderFactory
factory =DocumentBuilderFactory.newInstance(); - DocumentBuilder
builder =factory.newDocumentBuilder(); -
Document
doc =builder .parse(xml);
运行的时候报java.net.MalformedURLException:
- String
xml ="<?xml version="1.0"?>.......";//此处xml是通过接口获取到的xml字符串 -
DocumentBuilderFactory
factory =DocumentBuilderFactory.newInstance(); - DocumentBuilder
builder =factory.newDocumentBuilder(); -
Document
doc =builder .parse(newInputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))));
后来想想,是不是因为在xml字符串中没有指定编码的问题呢,具体问题没有寻根究底了。。。
InputStream inStr = new GZIPInputStream(con.getInputStream());
有的流是被压缩过的,需要解压后读取.
con.getContentEncoding() 记得看流的编码
前一篇:春华月咏·妄

加载中…