private static final long serialVersionUID = 1L; private Font font = new Font("宋体", Font.CENTER_BASELINE, 13); TextArea textarea = new TextArea(); JButton button[] = new JButton[3]; String buttonName[] = { "确定", "取消", "保存文件" }; JLabel label = new JLabel("请输入URL地址:"); JTextField urlfield = new JTextField(20);
JPanel panel = new JPanel();
URLStudyListener listener = new URLStudyListener(this);
private String file = "";
private FileDialog filesave;
public URLStudy() {
super.setTitle("资源文件的内容和属性查看器");
ImageIcon icon = new ImageIcon("195032.jpg"); setIconImage(icon.getImage());
public static void main(String[] args) { Hashtable<String, DataOutputStream> userList = new Hashtable<String, DataOutputStream>(); String name; DataInputStream dis; DataOutputStream dos;
try { ServerSocket serversocket = new ServerSocket(8088); while (true) { Socket socket = serversocket.accept(); dis = new DataInputStream(socket.getInputStream()); dos = new DataOutputStream(socket.getOutputStream());
name = dis.readUTF();
userList.put(name, dos);
new QQServerReader(name, dis, userList).start(); } } catch (IOException e) {
@Override public void run() { String info; Date date1 = new Date(); SimpleDateFormat sdf1 = new SimpleDateFormat("yy-MM-dd HH:mm:ss"); String time = "/t/t" + sdf1.format(date1);
info = dis.readUTF(); if (info.equals("^%#$^$jg4653|+=--09-89jh)*")) {// 暗号吻合,该用户退出聊天室 DataOutputStream dos = (DataOutputStream) userList .get(name);
dos.close(); dis.close(); userList.remove(name); Date date2 = new Date(); SimpleDateFormat sdf2 = new SimpleDateFormat( "yy-MM-dd HH:mm:ss"); time = "/t/t" + sdf2.format(date2);
transmitMessage(name + " 退出聊天室啦 !", "-------系统提示-------" + time); break; } else if (info.equals("L^%#$5@#h(8yh^+_)_)(=78UTh*%@!")) {// 暗号吻合,该用户离线 //info = ""; userList.remove(name); Date date2 = new Date(); SimpleDateFormat sdf2 = new SimpleDateFormat( "yy-MM-dd HH:mm:ss"); time = "/t/t" + sdf2.format(date2);
transmitMessage(name + " 离线 !", "-------系统提示-------" + time); break; } else if (info.equals("^&%()&(*85KJ$%@+_9)(80(8()*)(")) {// 暗号吻合,该用户重新上线 DataOutputStream dos = (DataOutputStream) userList .get(name); userList.put(name, dos); } else if (info.length() > 0) { Date date3 = new Date(); SimpleDateFormat sdf3 = new SimpleDateFormat( "yy-MM-dd HH:mm:ss"); time = "/t/t" + sdf3.format(date3);
Panel panel = new Panel(); panel.setLayout(new GridLayout(1, 4));
for (int i = 0; i < buttonName.length; i++) { button[i] = new JButton(buttonName[i]); button[i].setFont(font); button[i].addActionListener(listener); panel.add(button[i]); }