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

📄 sink.java

📁 The Javatm Telnet Application/Applet 很好用的
💻 JAVA
字号:
/* * This file is part of "The Java Telnet Application". * * (c) Matthias L. Jugel, Marcus Mei遪er 1996-2002. All Rights Reserved. * * Please visit http://javatelnet.org/ for updates and contact. * * --LICENSE NOTICE-- * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * --LICENSE NOTICE-- * */package de.mud.jta.plugin;import de.mud.jta.Plugin;import de.mud.jta.PluginConfig;import de.mud.jta.FilterPlugin;import de.mud.jta.VisualTransferPlugin;import de.mud.jta.PluginBus;import de.mud.jta.event.ConfigurationListener;import de.mud.jta.event.OnlineStatusListener;import de.mud.jta.event.TerminalTypeListener;import de.mud.jta.event.WindowSizeListener;import de.mud.jta.event.LocalEchoListener;import de.mud.jta.event.FocusStatus;import de.mud.jta.event.ReturnFocusListener;import de.mud.jta.event.AppletListener;import de.mud.jta.event.SoundRequest;import de.mud.jta.event.TelnetCommandRequest;import java.awt.Component;import java.awt.Panel;import java.awt.BorderLayout;import java.awt.Menu;import java.awt.MenuItem;import java.awt.Dimension;import java.awt.Font;import java.awt.Color;import java.awt.Scrollbar;import java.awt.Cursor;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.awt.event.FocusListener;import java.awt.event.FocusEvent;import java.awt.datatransfer.Clipboard;import java.awt.datatransfer.StringSelection;import java.awt.datatransfer.ClipboardOwner;import java.awt.datatransfer.Transferable;import java.awt.datatransfer.DataFlavor;import java.io.IOException;import java.io.InputStream;import java.net.URL;import java.net.MalformedURLException;import java.util.Properties;import java.util.Hashtable;import java.util.Enumeration;/** * The terminal plugin represents the actual terminal where the * data will be displayed and the gets the keyboard input to sent * back to the remote host. * <P> * <B>Maintainer:</B> Matthias L. Jugel * * @version $Id: Sink.java,v 1.5 2002/05/06 07:24:20 leo Exp $ * @author Matthias L. Jugel, Marcus Mei遪er */public class Sink extends Plugin   implements FilterPlugin, Runnable {  private final static int debug = 0;    private Thread reader = null;  public Sink(final PluginBus bus, final String id) {    super(bus, id);    // register an online status listener    bus.registerPluginListener(new OnlineStatusListener() {      public void online() {        if(debug > 0) System.err.println("Terminal: online "+reader);        if(reader == null) {          reader = new Thread();          reader.start();        }      }      public void offline() {        if(debug > 0) System.err.println("Terminal: offline");        if(reader != null)          reader = null;      }    });  }  /**   * Continuously read from our back end and drop the data.   */  public void run() {    byte[] t, b = new byte[256];    int n = 0;    while(n >= 0) try {      n = read(b);      /* drop the bytes into the sink :) */    } catch(IOException e) {      reader = null;      break;    }  }  protected FilterPlugin source;  public void setFilterSource(FilterPlugin source) {    if(debug > 0) System.err.println("Terminal: connected to: "+source);    this.source = source;  }  public FilterPlugin getFilterSource() {    return source;  }  public int read(byte[] b) throws IOException {    return source.read(b);  }  public void write(byte[] b) throws IOException {    source.write(b);  }}

⌨️ 快捷键说明

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