Re: Xml doc = dom.parseString(request.getReader());
gert wrote:
How can i [sic] make a BufferedReader a inputstream [sic], can i just cast it to a
input stream [sic] ?
No.
Parse requires a inputstream or string [sic]?
Or an InputSource, according to the Javadocs.
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
Documnet doc;
DocumentBuilder parser;
BufferedReader in = request.getReader();
doc = parser.parse(in);
casting doesn't work
InputStream in = (InputStream) request.getReader();
That's because there is no 'is-a' relationship between a Stream and a Reader.
Casting is used to make a supertype appear as a subtype, and only works when
the runtime instance actually is of that subtype. This time, getReader()
returns an instance that is not in any way an InputStream, so the cast cannot
work. It shouldn't even compile.
Any idea's [sic]?
<http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilder.html#parse(org.xml.sax.InputSource)>
chain to
<http://java.sun.com/javase/6/docs/api/org/xml/sax/InputSource.html>
specifically
<http://java.sun.com/javase/6/docs/api/org/xml/sax/InputSource.html#InputSource(java.io.Reader)>
Side note: spelling counts. In particular, case and whitespace count.
When posting code, copy-and-paste source (without any TAB characters) directly
into the message. That will prevent transcription errors, such as "Documnet
doc;" above.
--
Lew