Ok, sorry.
Basically I am writing an application which opens an XML file, parses
it (including validation against a remote schema) and then eventually
displays the data contained within the XML file pictorially (though I
haven't got onto this bit yet).
So far I have an application which can load a file and parse the XML
file (and validate it). At the moment I am running it from the command
line but the idea is that eventually I will create an executable jar
file.
Currently I have it so that only one file can be open at any one time
although eventually I intend to make it possible to have multiple files
open at once (using internal frames and desktop panes). Therefore, the
user will be able to close files without closing the application as a
whole. Therefore, I imagine it is fairly important to make sure that
inputs which have been finished with are 'closed' properly otherwise
you would end up with lots of inputs open not doing anything which
would slow it down.
I am aware that with classes such as BufferedReader there are methods
like close() which close that particular input. I am using a SAX
InputSource as shown in my previous post but after consulting the API I
found that there isn't a 'close' method or equivalent for this. In the
above post I was enquiring as to what the little snippet from the API I
posted actually meant and did I need to take any further action to
'close' the input.
Regards,
Steve
Oliver Wong - 17 Feb 2006 16:49 GMT
> Ok, sorry.
> Basically I am writing an application which opens an XML file, parses
[quoted text clipped - 21 lines]
> 'close' the input.
> Regards,
Sorry, it looks like I misunderstood what you wrote earlier:
<quote>
if
you do need to take some action when you have finished with an
InputSource, how do you go about it?
</quote>
I thought you meant you wanted to do something after the XML parser
finishes parsing, but before it closes the file, and you were asking how to
prevent the XML parser from closing the file.
My interpretation of the documentation is that the parser will close the
stream for you automatically. If you're really nervous about it though, what
I would do in your situation is to try to close the file anyway. And if an
exception gets thrown, like FileAlreadyClosedException or something similar,
then I'd just remove the code that closes the file twice.
- Oliver