Unfortunately, the XML parser closes the stream upon finishing reading. I don't understand why it does that really and I wouldn't recommend anyone to closing streams that they don't own. There might be a reason that I couldn't grasp that quickly.
Anyways, what you could do is having a BufferedInputStream, that does not close the wrapped InputSteam:
public static void main(String[] args) {
try (FileInputStream in = new FileInputStream(new File("myXML.xml"))){
XMLReader reader = new XMLReader();
InputStream stream = new BufferedInputStream(in) {
@Override
public void close() throws IOException {
// don't close
}
};
reader.read(stream);
} catch (Exception e) {
e.printStackTrace();
}
}