pipebundle.java
来自「Java p2p程序设计2002年版」· Java 代码 · 共 66 行
JAVA
66 行
package net.jxta.impl.shell.bin.ping;import java.io.*;import net.jxta.exception.*;import net.jxta.discovery.*;import net.jxta.endpoint.*;import net.jxta.pipe.*;import net.jxta.peergroup.*;import net.jxta.document.*;import net.jxta.id.*;import net.jxta.protocol.*;import java.util.*;/** * This class bundles a pipe advertisement with its input * and output pipes and their creation methods. */public class PipeBundle { private PipeAdvertisement ad; private PipeService ps; private InputPipe iPipe = null; private OutputPipe oPipe = null; /** Creates new PipeBundle */ public PipeBundle(PipeAdvertisement ad, PipeService ps) { this.ad = ad; this.ps = ps; } /** * Returns the input pipe associated with this PipeBundle */ public InputPipe getInputPipe() { try { if(iPipe==null) return (iPipe = (InputPipe)ps.createInputPipe(ad)); else return iPipe; } catch (IOException e) { return null; } } /** * Returns the output pipe associated with this PipeBundle */ public OutputPipe getOutputPipe() { try { if(oPipe==null) return (oPipe = (OutputPipe)ps.createOutputPipe(ad, 50000)); else return oPipe; } catch (IOException e) { return null; } } /** * Returns the advertisment associated with this PipeBundle */ public PipeAdvertisement getAdvertisement() { return ad; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?