[jdom-interest] read xml from socket inputstream

Stephan Trebels stephan at ncube.de
Sun Mar 30 22:07:01 PST 2003


A bit more background would help.  Which "length" do you want to
calculate?  I'll assume it's buf.length...

in short there are multiple ways to do this: either you add a framing
protocol (like minimal HTTP headers) e.g. you send something like

POST /context/for/this/xml
Content-Length: 12345

<?xml version="1.0" encoding="UTF-8" ?>
...

This makes sure you do get the relevant information, i.e. some
context, the length, and ... you start reading the XML.

But why do you want to read things into memory first?  Why don't you
just use inputStream and build the JDOM document using it?

Stephan

On Mon, Mar 31, 2003 at 01:46:30PM +0800, alex wrote:
> 
>    byte[] buf = new byte[length];
>    new DataInputStream(inputStream).readFully(buf);
>    InputStream in = new ByteArrayInputStream(buf);
> 
> 
> 
>    I've read the faq,and how can I calculate the length?

-- 
[------------ Stephan Trebels <stephan at ncube.de>, Consultant -----------]
company: nCUBE Deutschland GmbH, Hanauer Str. 56, 80992 Munich, Germany
phone: cell:+49 172 8433111  office:+49 89 149893 0  fax:+49 89 149893 50



More information about the jdom-interest mailing list