📄 inoutthread.java
字号:
package src;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Hashtable;
public class InOutThread extends Thread
{
private InputStream is;
private Hashtable htable;
public InOutThread(InputStream x,Hashtable y)
{
is = x;
htable = y;
// TODO 自动生成构造函数存根
}
public void run()
{
while(true)
{
try
{
String ip="";
while(true)
{
int ch = is.read();
if(ch==-1||ch=='\n')
{
break;
}
ip = ip+(char)ch;
}
Object o = htable.get(ip);
if(o!=null)
{
OutputStream os = (OutputStream)o;
String content = "";
while(true)
{
int ch = is.read();
if(ch==-1||ch=='\n')
{
break;
}
content = content+(char)ch;
}
content = content+'\n';
os.write(content.getBytes());
}
}
catch (IOException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -