⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inputstream.java

📁 ALGAE是一个快速创建算法演示的框架。目前支持的算法实现语言包括java和c
💻 JAVA
字号:
package edu.odu.cs.zeil.AlgAE.Server;import java.io.IOException;import edu.odu.cs.zeil.AlgAE.Server.MessageHandler;public class InputStream extends java.io.InputStream{  private String buffer;  private int pos;  private int buflen;  private MessageHandler msgs;    public InputStream(MessageHandler handler)  {    buflen = 0;    pos = 0;    msgs = handler;  }      /**     * Reads the next byte of data from this input stream. The value      * byte is returned as an <code>int</code> in the range      * <code>0</code> to <code>255</code>. If no byte is available      * because the end of the stream has been reached, the value      * <code>-1</code> is returned. This method blocks until input data      * is available, the end of the stream is detected, or an exception      * is thrown.      *     * @return     the next byte of data, or <code>-1</code> if the end of the     *             stream is reached.     * @exception  IOException  if an I/O error occurs.     */  public int read() throws java.io.IOException  {    while (pos >= buflen)      {	buffer = msgs.stdInput ();	buflen = buffer.length();	pos = 0;      }    int ch = buffer.charAt(pos);    ++pos;    return ch;  }    /**     * Returns the number of bytes that can be read from this input      * stream without blocking.      * @return     the number of bytes that can be read from this input stream     *             without blocking.     * @exception  IOException  if an I/O error occurs.     */    public int available() throws IOException {	return buflen - pos;    }    /**     * Closes this input stream and releases any system resources      * associated with the stream.      *     * @exception  IOException  if an I/O error occurs.     */    public void close() throws IOException    { buffer = null; }}

⌨️ 快捷键说明

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