java ÑéÖ¤Éí·ÝÖ¤ Éí·ÝÖ¤javaÑéÖ¤
ÒýÓÃÓÚ£ºhttp://blog.csdn.net/hhzxj2008/archive/2010/01/10/5171444.aspx
public static boolean validatePersonalId(String personalId) {
if ((personalId == null) || ((personalId.length() != 15) &&
(personalId.length() != 18))) {
return false;
}
int personalIdLength = personalId.length();
String regex = "[1-8]{1}[0-9]{" + (personalIdLength-2) + "}[0-9X]";
Pattern pattern = Pattern.compile(regex);
if (!pattern.matcher(personalId).matches()) {
return false;
}
// ½«ÀÏÉí·Ý֤ת»»ÎªÐÂÉí·ÝÖ¤
if (personalIdLength == 15) {
StringBuffer stringBuffer = new StringBuffer(personalId);
stringBuffer.insert(6, "19");
personalId = stringBuffer.toString();
}
// ¹æÔò
byte[] poss = { 2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4, 8, 5, 10, 9, 7 };
char[] possibleLast = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
int last = 0;
int[] pid = new int[18];
for (int i = 1; i < 18; i++){
int j = 17 - i;
pid[i - 1] = Integer.parseInt(personalId.substring(j, j + 1));
}
for (int i = 0; i < 17; i++){
last += poss[i] * pid[i];
}
last = last % 11;
if(possibleLast[last] == personalId.charAt(17)){
return true;
}
return false;
}
Ïà¹ØÎĵµ£º
ListµÄÓ÷¨
List°üÀ¨List½Ó¿ÚÒÔ¼°List½Ó¿ÚµÄËùÓÐʵÏÖÀà¡£ÒòΪList½Ó¿ÚʵÏÖÁËCollection½Ó¿Ú£¬ËùÒÔList½Ó¿ÚÓµÓÐCollection½Ó¿ÚÌṩµÄËùÓг£Ó÷½·¨£¬ÓÖÒòΪListÊÇÁбíÀàÐÍ£¬ËùÒÔList½Ó¿Ú»¹ÌṩÁËһЩÊʺÏÓÚ×ÔÉíµÄ³£Ó÷½·¨£¬Èç±í1Ëùʾ¡£
±í1 List½Ó¿Ú¶¨ÒåµÄ³£Ó÷½·¨¼°¹¦ÄÜ
´Ó±í1¿ÉÒÔ¿´³ö£¬List½Ó¿ÚÌṩµÄÊʺÏÓÚ×ÔÉíµÄ ......
¼ÙÉèÒ»¸öphotoshop¹¤³Ì£¬¶ÔÕÕÆ¬¿ÉÒÔÓкܶàÖÖ·ç¸ñЧ¹ûµÄ×°ÊΣ¬ÓÐһЩװÊÎЧ¹ûphotoshop¿ª·¢×é¿ÉÒÔ×Ô¼º¿ª·¢²¢ÇÒ·ÅÔÚ·¢²¼°æ±¾ÀïÃæ·¢²¼¡£ÄÇô´ó¼Ò¶¼¿ÉÒÔʹÓÃÕâÖÖЧ¹û¡£µ«ÊÇÈç¹ûÓû§Ï뿪·¢×Ô¼ºµÄ×°ÊÎЧ¹ûÔõô°ì£¿ ÄѵÀÅܵ½ps¿ª·¢×éÈ¥£¬°Ñ×Ô¼ºµÄ´úÂë¸øÈ˼ң¬ÈÃÈ˼ҰÑ×Ô¼ºµÄ´úÂë·Å½øÈ˼ҵÄps´ó¹¤³ÌÀïÃæ£¬±àÒëÈ»ºó·¢²¼µ½ÏÂÃæÒ»¸öе ......
public static boolean telnetTest() {
boolean b=false;
Socket server = null;
try {
server = new Socket();
InetSocketAddress address = new InetSocketAddress(
"192.168.1.101", 80);
server.connect(address, 5000);
b=true;
} catch (UnknownHostException e) {
e.printSta ......
ÔÚjava.util °üÏÂÃæÓÐÒ»¸öÀà Properties£¬¸ÃÀàÖ÷ÒªÓÃÓÚ¶ÁÈ¡ÒÔÏîÄ¿µÄÅäÖÃÎļþ£¨ÒÔ£®properties½áβµÄÎļþºÍxmlÎļþ£©¡£
PropertiesµÄ¹¹Ô캯ÊýÓÐÁ½¸ö£¬Ò»¸ö²»´ø²ÎÊý£¬Ò»¸öʹÓÃÒ»¸öProperties¶ÔÏó×÷Ϊ²ÎÊý¡£
ʹÓÃProperties¶ÁÈ¡£®propertiesÎļþ
test.propertiesÎļþÈçÏ£º
#²âÊÔ»·¾³ÅäÖãºÆ½Ì¨Â·¾¶ÅäÖÃ
jstrd_home=D:/T ......