> sorry but can you explain me, how does
> org/apache/xerces/readers/CharReader.java come into picture with this
code?
> Also, I tried using BufferedReader, setting mark() explicitly but
nothing
> seems to work
I had the same problem when parsing from the InputStream of a Socket.
The fact is that when you construct an InputSource and let the parser
parse from it, the InputSource will close the Stream it was supplied with,
although
the documentation will let you think that it doesnt get closed.
The InputSource will build an Reader around your InputStream or Reader
an will close it in /org/apache/xerces/readers/CharReader which it uses to
read from it.
In the java-api closing an reader or inputstream will also close the
underlying
stream. So, when the CharReader class is closing your Reader you won't be
able to read again from it.
You are using a StringReader, the easy Solution for you would be to Wrap
this
Reader in another one which doesn't close the "wrapped" Reader:
public class WrapReader extends FilterReader {
public WrapReader(Reader in) {
super(in);
}
public void close() {
System.out.println("WrapReader avoiding close of Reader!");
}
}
And using in your code:
java.io.StringReader inString = new StringReader(MsgHeader);
WrapReader wrapReader = new WrapReader(inString);
...//using wrapReader
inString.reset();
...//using wrapReader
The other solution i pointed out to you is to fix the bug in xerces,
by commenting out line 175 in /org/apache/xerces/readers/CharReader.java.
This is actually where the streams get closed. you can find it out by
throwing a Exception in your WrapReder.close() and printing a StackTrace.
I hope this helps.
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]