当我尝试将InputStream解析为Document时,我收到此错误:
java.io.IOException:读取失败:EBADF(错误的文件编号)
代码:
private String readLanguageXML(InputStream file)
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try
{
DocumentBuilder builder = factory.newDocumentBuilder();
Document dom = builder.parse(file); // ERROR HERE
file.close();
Element root = dom.getDocumentElement();
NodeList items = root.getChildNodes();
for (int j=0; j<items.getLength(); j++)
{
try
{
Node dato = items.item(j);
String etiqueta = dato.getAttributes().item(0).getNodeValue();
languageMap.put(etiqueta, dato.getTextContent());
}
catch(NullPointerException npe)
{
npe.printStackTrace();
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
return "";
}