ÊÕ¼¯µ½µÄjava ÕýÔòÑéÖ¤
Java´úÂ룺
import java.util.regex.*;
public final class RegExpValidator
{
/**
* ÑéÖ¤ÓÊÏä
* @param ´ýÑéÖ¤µÄ×Ö·û´®
* @return Èç¹ûÊÇ·ûºÏµÄ×Ö·û´®,·µ»Ø <b>true </b>,·ñÔòΪ <b>false </b>
*/
public static boolean isEmail(String str)
{
String regex = "^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
return match(regex, str);
}
/**
* ÑéÖ¤IPµØÖ·
* @param ´ýÑéÖ¤µÄ×Ö·û´®
* @return Èç¹ûÊÇ·ûºÏ¸ñʽµÄ×Ö·û´®,·µ»Ø <b>true </b>,·ñÔòΪ <b>false </b>
*/
public static boolean isIP(String str)
{
String num = "(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)";
String regex = "^" + num + "\\." + num + "\\." + num + "\\." + num + "$";
return match(regex, str);
}
/**
* ÑéÖ¤ÍøÖ·Url
* @param ´ýÑéÖ¤µÄ×Ö·û´®
* @return Èç¹ûÊÇ·ûºÏ¸ñʽµÄ×Ö·û´®,·µ»Ø <b>true </b>,·ñÔòΪ <b>false </b>
*/
public static boolean IsUrl(String str)
{
String regex = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?";
return match(regex, str);
}
/**
* ÑéÖ¤µç»°ºÅÂë
* @param ´ýÑéÖ¤µÄ×Ö·û´®
* @return Èç¹ûÊÇ·ûºÏ¸ñʽµÄ×Ö·û´®,·µ»Ø <b>true </b>,·ñÔòΪ <b>false </b>
*/
public static boolean IsTelephone(String str)
{
String regex = "^(\\d{3,4}-)?\\d{6,8}$";
return match(regex, str);
}
/**
* ÑéÖ¤ÊäÈëÃÜÂëÌõ¼þ(×Ö·ûÓëÊý¾Ýͬʱ³öÏÖ)
* @param ´ýÑéÖ¤µÄ×Ö·û´®
* @return Èç¹ûÊÇ·ûºÏ¸ñʽµÄ×Ö·û´®,·µ»Ø <b>true </b>,·ñÔòΪ <b>false </b>
*/
public static boolean IsPassword(String str)
{
String regex = "[A-Za-z]+[0-9]";
return match(regex, str);
}
/**
* ÑéÖ¤ÊäÈëÃÜÂ볤¶È (6-18λ)
* @param ´ýÑéÖ¤µÄ×Ö·û´®
* @return Èç¹ûÊÇ
Ïà¹ØÎĵµ£º
import java.util.regex.*;
public final class RegExpValidator
{
/**
* ÑéÖ¤ÓÊÏä
* @param ´ýÑéÖ¤µÄ×Ö·û´®   ......
JavaÓïÑÔµÄÊäÈëÊä³ö¹¦ÄÜÊÇÊ®·ÖÇ¿´ó¶øÁé»îµÄ£¬ÃÀÖв»×ãµÄÊÇ¿´ÉÏÈ¥ÊäÈëÊä³öµÄ´úÂë²¢²»ÊǺܼò½à£¬ÒòΪÄãÍùÍùÐèÒª°ü×°Ðí¶à²»Í¬µÄ¶ÔÏó¡£ÔÚJavaÀà¿âÖУ¬IO²¿·ÖµÄÄÚÈÝÊǺÜÅÓ´óµÄ£¬ÒòΪËüÉæ¼°µÄÁìÓòºÜ¹ã·º:±ê×¼ÊäÈëÊä³ö£¬ÎļþµÄ²Ù×÷£¬ÍøÂçÉϵÄÊý¾ÝÁ÷£¬×Ö·û´®Á÷£¬¶ÔÏóÁ÷£¬zipÎļþÁ÷....±¾ÎĵÄÄ¿µÄÊÇΪ´ó¼Ò×öÒ»¸ö¼òÒªµÄ½éÉÜ¡£
¡¡¡¡Á ......
À¬»øÊÕ¼¯¼¸ºõÊÇÿ¸ö¿ª·¢ÈËÔ±¶¼Ï²°®µÄÒ»¸ö Java™ Æ½Ì¨ÌØÐÔ£¬Ëü¼ò»¯ÁË¿ª·¢£¬Ïû³ýÁËËùÓÐÖÖÀàµÄDZÔÚ´úÂë´íÎ󡣿ɾ¡¹ÜÀ¬»øÊÕ¼¯Ò»°ãÀ´Ëµ¿ÉÒÔÈÃÄúÎÞÐè½øÐÐ×ÊÔ´¹ÜÀí£¬ÓÐʱºòÄú»¹ÊDZØÐë×Ô¼º½øÐÐһЩÄÚÎñ´¦Àí¡£
ÏÔʽµØÊÍ·Å×ÊÔ´
Java ³ÌÐòÖÐʹÓõľø´ó¶àÊý×ÊÔ´¶¼ÊǶÔÏó£¬À¬»øÊÕ¼¯ÔÚÇåÀí¶ÔÏó·½Ãæ×öµÃºÜºÃ¡£Òò´Ë£¬Äú¿ÉÒÔʹÓÃÈÎ ......
1)¾²Ì¬±äÁ¿±¾Éí²»»á±»»ØÊÕ
2)¾²Ì¬±äÁ¿ËùÒýÓõĶÔÏóÊÇ¿ÉÒÔ»ØÊյġ£
µÚÒ»µã´ó¼ÒÓ¦¸ÃûÓÐÒÉÎÊ£¬ÏÂÃæÎÒÖ¤Ã÷µÚ£²µã£º
¿´ÏÂÃæµÄÀý×Ó¼°×¢ÊÍ¡£×Ô¼º¿ÉÒÔÔËÐÐÊÔÒ»ÏÂ,¡¡×¢Òâ¼ÓÉÏ-verbose:gc²ÎÊý
java -verbose:gc TestStaticGc
// TestStaticGc.java
public class TestStaticGc {
& ......
Êý¾Ý¿âÁ¬½Ó
Á÷ÊÇÖ¸Ò»Á¬´®Á÷¶¯µÄ×Ö·û£¬ÊÇÒÔÏȽøÏȳöµÄ·½Ê½´¦ÀíµÄ¡£
¹¹ÔìÒ»¸öÎļþÊäÈëÁ÷¶ÔÏó£ºInputStream o = new FileInputStream(“a.txt&rdquo ......