📄 multichat.java
字号:
package PC;
import java.io.*;
import java.net.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.event.*;
public class MultiChat extends Thread
{
private OutputStreamWriter osw=null;
private BufferedReader br;
private JTextArea chatroom;
private String line;
private Socket fc=null;
private String name;
private final static String NEW_LINE = System.getProperty("line.separator");
public MultiChat(JTextArea content,OutputStreamWriter osw,BufferedReader br,Socket skt,String name)
{
this.osw=osw;
this.br=br;
this.chatroom=content;
fc=skt;
this.name=name;
}
public void run()
{
try
{
line = br.readLine();
}
catch(IOException ioe)
{
}
while(true)
{
if(line.length()>=28)
{
if(line.substring(0, 27).equals("Other size sent you a file:"))
{
chatroom.append(NEW_LINE+"System: " +line);
MultiThread rec=new MultiThread(fc,"rec",osw,chatroom);
rec.start();
}
else
{
chatroom.append(NEW_LINE+line);
}
}
else
{
if(line.equals("File sent successfully."))
chatroom.append(NEW_LINE+"System: " +line);
else
chatroom.append(NEW_LINE+line);
}
try
{
Thread.sleep(1000);
}
catch(InterruptedException ie)
{
}
try
{
line=br.readLine();
}
catch(IOException ioe)
{
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -