gpt4 book ai didi

android - 无法解码流 : fileNotFoundException

转载 作者:行者123 更新时间:2023-11-29 17:46:43 24 4
gpt4 key购买 nike

基本上,我使用 DOM 解析器从 ListView 中的 RSS 提要中检索标题、描述、pubDate 和缩略图。这是我的示例代码。

 public ArrayList<HashMap<String, String>> processXML(
InputStream inputStream) throws Exception {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory
.newDocumentBuilder();
Document xmlDocument = documentBuilder.parse(inputStream);
Element rootElement = xmlDocument.getDocumentElement();
L.m("" + rootElement.getTagName());
NodeList itemsList = rootElement.getElementsByTagName("item");
NodeList itemChildren = null;
Node currentItem = null;
Node currentChild = null;
NamedNodeMap mediaThumbnailAttr = null;
Node currentAttribute=null;
int count = 0;
ArrayList<HashMap<String, String>> results = new ArrayList<>();
HashMap<String, String> currentMap = null;
for (int i = 0; i < itemsList.getLength(); i++) {
currentItem = itemsList.item(i);
itemChildren = currentItem.getChildNodes();
currentMap = new HashMap<>();
for (int j = 0; j < itemChildren.getLength(); j++) {
currentChild = itemChildren.item(j);
if (currentChild.getNodeName().equalsIgnoreCase("title")) {
// L.m(currentChild.getTextContent());
currentMap.put("title", currentChild.getTextContent());
}
if (currentChild.getNodeName().equalsIgnoreCase("pubDate")) {
// L.m(currentChild.getTextContent());
currentMap
.put("pubDate", currentChild.getTextContent());
}
if (currentChild.getNodeName().equalsIgnoreCase(
"description")) {
// L.m(currentChild.getTextContent());
currentMap.put("description",
currentChild.getTextContent());
}

if(currentChild.getNodeName().equalsIgnoreCase("media:thumbnail")){
//L.m(""+currentChild.getTextContent());
mediaThumbnailAttr = currentChild.getAttributes();
for(int k=0;k<mediaThumbnailAttr.getLength();
k++){
currentAttribute = mediaThumbnailAttr.item(k);
if(currentAttribute.getNodeName()
.equalsIgnoreCase("url")){
count++;

//L.m(currentChild.getAttributes().item(0).getTextContent());

}
//L.m();
currentMap.put("imageURL", currentChild
.getAttributes().item(0).getTextContent());
}
count=0;
}
}
if (currentMap != null && !currentMap.isEmpty()) {
results.add(currentMap);
}
count = 0;
}
return results;
}
}
}

我的解析器正确读取了前三个标签。但是缩略图给我带来了问题,并抛出异常...

        Unable to decode stream: java.io.FileNotFoundException:   
/http:/i.dailymail.co.uk/i/pix/2014/09/27/1411832985119_Puff_Image_galleryImage_SUNDERLAND_ENGLAND_SEPTEM.JPG: open failed: ENOENT (No such file or directory).

有没有问题 setImageURI(Uri.parse(currentItem.get("imageURL")));

最佳答案

错误是:

Unable to decode stream: java.io.FileNotFoundException:   
/http:/i.dailymail.co.uk/i/pix/2014/09/27/1411832985119_Puff_Image_galleryImage_SUNDERLAND_ENGLAND_SEPTEM.JPG: open failed: ENOENT (No such file or directory).

在 URL 开始之前看到“/”。这导致了 FileNotFoundException。因此,首先,请确保您在回复中获得正确的 URL。

为了测试,尝试使用硬编码的 url:

holder.articleImage.setImageURI(Uri.parse("http:/i.dailymail.co.uk/i/pix/2014/0‌​9/27/1411832985119_Puff_Image_galleryImage_SUNDERLAND_ENGLAND_SEPTEM.JPG"));

我想这应该没问题。因此,只需在响应中进行更正,就可以开始了。

关于android - 无法解码流 : fileNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26077016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com