Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've resolved with this four class:</p> <p>1)</p> <pre><code>public class XMLOutputStream extends ByteArrayOutputStream { private DataOutputStream outchannel; public XMLOutputStream(OutputStream outchannel) { super(); this.outchannel = new DataOutputStream(outchannel); } public void send() throws IOException { byte[] data = toByteArray(); outchannel.writeInt(data.length); outchannel.write(data); reset(); } } </code></pre> <p>2)</p> <pre><code>public class XMLSender { public static void send(Document tosend, OutputStream channel) throws TransformerConfigurationException, IOException { XMLOutputStream out = new XMLOutputStream(channel); StreamResult sr = new StreamResult(out); DOMSource ds = new DOMSource(tosend); Transformer tf = TransformerFactory.newInstance().newTransformer(); try { tf.transform(ds, sr); } catch (TransformerException ex) { Logger.getLogger(XMLSender.class.getName()).log(Level.SEVERE, null, ex); } out.send(); } } </code></pre> <p>3)</p> <pre><code>public class XMLInputStream extends ByteArrayInputStream { private DataInputStream inchannel; public XMLInputStream(InputStream inchannel) { super(new byte[2]); this.inchannel = new DataInputStream(inchannel); } public void recive() throws IOException { int i = inchannel.readInt(); byte[] data = new byte[i]; inchannel.read(data, 0, i); this.buf = data; this.count = i; this.mark = 0; this.pos = 0; } } </code></pre> <p>4)</p> <pre><code>public class XMLReceiver { public static Document receive(InputStream channel) throws ParserConfigurationException, TransformerConfigurationException, IOException, SAXException { DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); Document request = null; XMLInputStream xmlin = new XMLInputStream(channel); xmlin.recive(); request = docBuilder.parse(xmlin); return request; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload