62,636
社区成员




- //省略生成XML的代码
- Document doc = new Document(root);
- XMLOutputter XMLOut = new XMLOutputter(format);
- //生成XML字符串,即XML文件的内容,包含很多换行符
- String xmlString = XMLOut.outputString(doc);
- //发送XML字符串
- PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
- out.println(xmlString);
- out.flush();
- BufferedReader in = new BufferedReader(new InputStreamReader(processSocket.getInputStream()));
- String msg = "";
- String temp = "";
- ///////////////////////////////////////////////////////////////////////
- //这里读完后就阻塞了,抛出异常,该怎么样才能知道XML文件内容传完了呢?//
- ///////////////////////////////////////////////////////////////////////
- while ((temp = in.readLine()) != null) {
- msg += temp;
- }
<iq type='set' from='juliet@capulet.lit/chamber' id='publish2'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='urn:xmpp:avatar:metadata'>
<item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'>
<metadata xmlns='urn:xmpp:avatar:metadata'>
<info bytes='23456'
height='64'
id='222f4b3c50d7b0df729d299bc6f8e9ef9066971f'
type='image/gif'
url='http://avatars.example.org/happy.gif'
width='64'/>
</metadata>
</item>
</publish>
</pubsub>
</iq>