I have to parse xml from the content of a Jetty buffer using SAX.
From my ContentExchange I can call getRequestContent, and then I get a Buffer
I need an InputStream, or an InputSoruce or a String or a File in order to parse it with SAX. How can I convert the buffer to one of those, and which way is the most efficient?
It looks like something obvious, but I can not find any information in the documentation.
Apologies for answering an old question, but someone (such as myself) may stumble upon this in the future.
Jetty’s
Bufferclass implements awriteTo(OutputStream)method. A simple solution would be to do the following:Then for each
Bufferreceived, do:This way you can stream responses without need for caching them.
EDIT:
Of course, make sure that
processBuffer()and readers of thePipedInputStreamare running in separate threads to avoid potential deadlock.