output.java

来自「KWIC系统 采用管道/过滤器风格实现」· Java 代码 · 共 47 行

JAVA
47
字号
//package kwic.pf;



import java.io.IOException;
import javax.swing.*;
import javax.swing.text.*;

/* Output prints the data from its input pipe on the standard output.*/


public class Output extends Filter
{
	private JTextArea resultPane;
	private String filterType;

    public Output(Pipe input, JTextArea resultPanel,String filterType)
    {
         super(input, null);
         resultPane = resultPanel;
         this.filterType=filterType;
    }

/* This method writes the data from the input pipe on the standard output. */

  protected void transform()
  {
    try
    {
      int c = input_.read();
      while(c != -1)
      {
         System.out.print((char) c);
         resultPane.append(""+(char)c);
         c = input_.read();
      }
      if(filterType.compareTo("a2")==0 ||filterType.compareTo("a3")==0 )
            System.out.println();
    }
    catch(IOException exc){
      exc.printStackTrace();
      System.err.println("KWIC Error: Broken pipe");
      System.exit(1);
    }
  }
}

⌨️ 快捷键说明

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