Пожалуйста, посмотрите на то, что я сделал
private InputSource getContent(String fName) throws SAXException, IOException, ServiceException {
// Some code here
if(currentNodeRef != null)
{
ContentReader reader = contentService.getReader(currentNodeRef,ContentModel.PROP_CONTENT);
InputStream inputStream = null;
try
{
inputStream = new BufferedInputStream(reader.getContentInputStream(),16384);
return new InputSource(inputStream);
}
finally
{
if(inputStream!=null)
try
{
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return new InputSource();
}
В моем методе parseDocument я вызвал вышеуказанный метод.
parseDocRoot(getContent(fName),path);
В parseDocRoot
public void parseDocRoot (InputSource ins, String path) throws SAXException, IOException,
ParserConfigurationException, ServiceException
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
return new InputSource(new ByteArrayInputStream(new byte[0]));
}
});
Document doc = builder.parse(ins);
NodeList list = doc.getChildNodes();
parseDocument(list,path);
}
Я получил ошибку, сказав, что поток не закрыт, и во время отладки вышеуказанного кода я обнаружил, что ошибка находится в строке
Document doc = builder.parse(ins);
Пожалуйста, помогите мне найти решение.