java Pattern使用
public static boolean isCheckN(String pInput) {
String regEx = "^[0-9]+$";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(pInput);
return m.find();
}
public static boolean isCheckE(String pInput)
{
if (!pInput.equals("")){
if (!Pattern.matches("XXXX",pInput)){
return false;
}
}
return true;
}
相关文档:
运用加密技术保护Java源代码
java
程序的源代码很容易被别人偷看。只要有一个反编译器,任何人都可以分析别人的代码。本文讨论如何在不修改原有程序的情
况下,通过
加密
技术保护源代
码。
一、为什么要
加密
?
......
1. Multiply-Thread
Locks offer two primary features: mutual exclusion and visibility. Mutual exclusion means only one thread at a time may hold a given lock, so only one thread at a time will be using the shared data. Visibility is to ensure that changes made to shared data prior to releasing a lo ......
代码如下:
package com.test.j2se;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5 {
/**数据加密
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
MessageDigest code = MessageD ......
用ServerSocket和Socket来编写服务器程序和客户程序,是Java网络编程的最基本的方式。这些服务器程序或客户程序在运行过程中常常会阻塞。例如当一个线程执行ServerSocket的accept()方法时,假如没有客户连接,该线程就会一直等到有了客户连接才从accept()方法返回。再例如当线程执行Socket的read()方法时,如果输入流中没有 ......
服务器中转消息,是费时的事,可以加入多线程。这样以来,会产生很多线程。可以运用线程池来管理。
这里运用java.util.concurrent包的Executors.newCachedThreadPool来管理。
废话少说,上代码:
服务器端:MySocketServer.java
/*
* To change this template, choose Tools | Templates
* and open the ......