javastreamsax

Java SAXParser - keep InputStream open


I've a BufferedInputStream from which I want to parse XML with SAXParser but then reuse it again (eg. mark(int) & reset()). However this stream is closed in parse() method. Is it possible to somehow tell SAXParser to leave it open? The last resort is to wrap this stream with un-closeable stream.

Thank you.


Solution

  • How about something like:

    class WontCloseBufferedInputStream extends BufferedInputStream {
      public void close () {
        // Do nothing.
      }
    
      public void reallyClose() {
        super.close ();
      }
    }