outputstream.java

来自「ALGAE是一个快速创建算法演示的框架。目前支持的算法实现语言包括java和c」· Java 代码 · 共 52 行

JAVA
52 行
字号
package edu.odu.cs.zeil.AlgAE.Server;import java.io.IOException;import edu.odu.cs.zeil.AlgAE.Server.MessageHandler;public class OutputStream extends java.io.OutputStream{  private StringBuffer buffer;  private MessageHandler msgs;    public OutputStream (MessageHandler handler)  {    buffer = new StringBuffer();    msgs = handler;  }    /**   * Writes the specified byte to this output stream.    *   * @param      b   the <code>byte</code>.   * @exception  IOException  if an I/O error occurs.   */  public void write(int b) throws IOException  {    buffer.append ((char)b);  }  /**   * Flushes this output stream and forces any buffered output bytes    * to be written out.    *   * @exception  IOException  if an I/O error occurs.   */  public void flush() throws IOException {    msgs.stdOutput (buffer.toString());    buffer = new StringBuffer();  }    /**     * Closes this output stream and releases any system resources      * associated with this stream.      *     * @exception  IOException  if an I/O error occurs.     */    public void close() throws IOException {      buffer = null;    }}

⌨️ 快捷键说明

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