<Peer>node1</Peer> <KeyWords>Netpeer group by default</Keywords> <PeerId> jxta://59616261646162614A78746150325033DB1EB6636DCE4B2990CA888B36CD96C7000 0000000000000000000000000000000000000000000000000000000000301 </PeerId> <TransportAddress>tcp://169.254.101.152:9700/</TransportAddress>
-f 开关是必须的。它表示紧接在后面的是一个文件名;这个用法跟 UNIX 的 tar 命令相似。省略它将导致未定义的行为,包括异常!
现在,将导入的文件作为一个标记值(与名为 dwTag 的标记联系在一起)附加到消息上。从概念上说,我们是在把属性附加到消息对象中。属性将与消息一起通过管道传送并可在另一端将它拆离。在下层,一个额外的 XML 片段被插入到结构化文档(消息)中,它包含附加文档,并以标记值命名;相关的报头也被修改以反映新的、更大的大小。用 put 命令就可以完成这一切。稍后,可以用 get 命令从消息中抽取相同的标记值,get 命令通过逆向进行上述过程找回所导入的文件。
try { myInpStream = myMesg.pop (tagName); println("tagName used is " + tagName); myStructDoc = StructuredDocumentFactory.newStructuredDocument ( new MimeMediaType ("text/xml"), myInpStream); OutputStream out = new ByteArrayOutputStream();
myStructDoc.sendToStream( out ); println("received a message..."); print ( out.toString() ); } catch (Exception e) { println("waitptext: failed in messge receive"); return ShellApp.appMiscError; } return ShellApp.appNoError; }
JXTA>waitptext dwTag created a pipe advertisement... created an input pipe based on the advertisement... published the pipe advertisement to the group... waiting at the input pipe for a message...
tagName used is dwTag received a message... <?xml version="1.0"?> <ShellDoc> <Item> This is a simple file for Jxta transfer. It can contain anything. </Item> </ShellDoc> JXTA>