Java中路由器模式
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.io.Serializable;
import java.rmi.Naming;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class RunRouterPattern {
public static void main(String[] arguments) {
System.out.println("Example for the Router pattern");
System.out
.println("This code same will create a series of GUIs, and use");
System.out
.println(" the Router pattern to map message notifications between");
System.out
.println(" them. In this code example, the Router will send messages");
System.out
.println(" between the GUI clients based on the following mapping:");
System.out.println();
System.out.println("\tGUI # 1:\tGUI #2\tGUI #3");
System.out.println("\tGUI # 2:\tGUI #1\tGUI&nbs
相关文档:
Java学习从入门到精通
一、 JDK (Java Development Kit)
JDK是整个Java的核心,包括了Java运行环境(Java Runtime Envirnment),一堆Java工具和Java基础的类库(rt.jar)。不论什么Java应用服务器实质都是内置了某个版本的JDK。因此掌握JDK是学好Java的第一步。最主流的J ......
正则表达式在字符串处理上有着强大的功能,sun在jdk1.4加入了对它的支持
下面简单的说下它的4种常用功能:
查询:
以下是代码片段:
String str="abc efg ABC";
String regEx="a|f"; //表示a或f
Pattern p=P ......
在获取文本的时候,经常遇到数据格式的问题,需要判断或转换。
本文旨在解决全角符号转换为半角符号的问题。
网上大体有两种方法:转换编码或则替换。
我使用的是转换编码
1. string checkStr="123456";
2. //判断是否包含全角字符[1]
3. if(checkStr.length() != checkStr.getBytes().length) ......