outputpipe.java

来自「MoMEUnit是一个单元测试的J2ME的应用程序xUnit架构实例。这是来自J」· Java 代码 · 共 101 行

JAVA
101
字号
package org.momeunit.ant.core;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.io.PipedInputStream;import java.io.PipedOutputStream;/** * Abstract class that every output processing pipe should extend. Provides base * functionality. Like setting input stream, requesting pipe etc. *  * @author Sergio Morozov * @version 1.1.2 */public abstract class OutputPipe implements Runnable{  private InputStream in = null;  private OutputStream out = null;  /**   * Initializes OutputPipe with given {@link InputStream}.   *    * @param pipeIn   *          the {@link InputStream} to set.   * @since 1.1   */  public OutputPipe(InputStream pipeIn)  {    super();    this.in = pipeIn;  }  /**   * Starts processing input and sending it to a pipe if requested.   *    * @since 1.1   */  public void start()  {    if (this.getInputStream() != null) new Thread(this).start();  }  /**   * Returns the {@link OutputStream} of the pipe.   *    * @return the {@link OutputStream} of the pipe.   * @since 1.1   */  protected OutputStream getOutpuStream()  {    return this.out;  }  /**   * Returns requested {@link InputStream} of pipe.   *    * @return the requested {@link InputStream} of pipe.   * @throws IOException   *           if an error occurs while creating pipe.   * @since 1.1   */  public InputStream getPipeOutput() throws IOException  {    PipedInputStream res = new PipedInputStream();    this.out = new PipedOutputStream(res);    return res;  }  /**   * Returns input of this OutputPipe.   *    * @return the input of this OutputPipe.   * @since 1.1   */  public InputStream getInputStream()  {    return this.in;  }  /**   * Sets input of this OutputPipe.   *    * @param in   *          input of this OutputPipe.   * @since 1.1   */  public void setInputStream(InputStream in)  {    this.in = in;  }  /*   * @see java.lang.Runnable#run()   */  public void run()  {}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?