java ÕýÔò±í´ïʽ¹¤¾ßÀà
//ʹÓÃabstractÄ¿µÄÊÇΪÁËÈÃʹÓÃÕßÖ»Äܵ÷ÓÃgetInstance»ñȡʵÀý
public abstract class RegexUtil {
public static void main(String[] args) {
RegexUtil ru = RegexUtil.getInstance();
String regexp = "(\\d+.\\d+.\\d+.\\d+):(\\d+)";
String data = "ldap://192.168.16.152:389/";
System.out.println(">>>" + ru.matchGroup(regexp, data).size());
}
public List<String> matchGroup(String regexp, String data) {
Pattern p = Pattern.compile(regexp);
Matcher matcher = p.matcher(data);
List<String> list = null;
while (matcher.find()) {
int length = matcher.groupCount();
list = new java.util.ArrayList<String>(length);
for (int i = 1; i < length + 1; i++) {
list.add(matcher.group(i));
}
}
return list;
}
private static RegexUtil ru = null;
//µ¥Ì«Ä£Ê½
public static RegexUtil getInstance() {
if (ru == null) {
ru = new RegexUtil() {
};
}
return ru;
}
}
Ïà¹ØÎĵµ£º
ÇëÌṩһ¸ö¶ÔiµÄÉùÃ÷£¬½«ÏÂÃæµÄÑ»·×ª±äΪһ¸öÎÞÏÞÑ»·¡£Õâ¸öÑ»·²»ÐèҪʹÓÃÈκÎ5.0°æµÄÌØÐÔ£º
while (i != 0 && i == -i) {
}
ÕâÈÔÈ»ÊÇÒ»¸öÑ»·¡£ÔÚ²¼¶û±í´ïʽ(i != 0 && i == -i)ÖУ¬Ò»Ôª¼õºÅ²Ù×÷·û×÷ÓÃÓÚi£¬ÕâÒâζ×ÅËüµÄÀàÐͱØÐëÊÇÊý×ÖÐ͵ģºÒ»Ôª¼õºÅ²Ù×÷·û×÷ÓÃÓÚÒ»¸ö·ÇÊý×ÖÐͲÙ×÷ÊýÊÇ·Ç·¨µÄ¡£Òò´Ë£ ......
ÏÂÃæµÄ³ÌÐòÔÚÄ£·ÂÒ»¸ö¼òµ¥µÄʱÖÓ¡£ËüµÄÑ»·±äÁ¿±íʾһ¸öºÁÃë¼ÆÊýÆ÷£¬Æä¼ÆÊýÖµ´Ó0¿ªÊ¼Ö±ÖÁһСʱÖаüº¬µÄºÁÃëÊý¡£Ñ»·ÌåÒÔ¶¨ÆÚµÄʱ¼ä¼ä¸ô¶ÔÒ»¸ö·ÖÖÓ¼ÆÊýÆ÷Ö´ÐÐÔöÁ¿²Ù×÷¡£×îºó£¬¸Ã³ÌÐò½«´òÓ¡·ÖÖÓ¼ÆÊýÆ÷¡£ÄÇôËü»á´òÓ¡³öÊ²Ã´ÄØ£¿
public class Clock {
public static void main(String[] args) {
int minutes ......
±¾ÃÕÌâ²âÊÔµÄÊÇÄã¶ÔijЩ¹æÔòµÄÕÆÎճ̶ȣ¬ÕâЩ¹æÔòÓÃÓÚÉùÃ÷´Ó·½·¨ÖÐÅ׳ö²¢±»catchÓï¾ä¿éËù²¶»ñµÄÒì³£¡£ÏÂÃæµÄÈý¸ö³ÌÐòÿһ¸ö¶¼»á´òӡЩʲô£¿²»Òª¼ÙÉèËüÃǶ¼¿ÉÒÔͨ¹ý±àÒ룺
import java.io.IOException;
public class Arcane1 {
public static void main(String[] args) {
try {
System.out.p ......
ÏÂÃæµÄ·½·¨½«Ò»¸öÎļþ¿½±´µ½ÁíÒ»¸öÎļþ£¬²¢ÇÒ±»Éè¼ÆÎªÒª¹Ø±ÕËüËù´´½¨µÄÿһ¸öÁ÷£¬¼´Ê¹ËüÅöµ½I/O´íÎóÒ²ÒªÈç´Ë¡£Òź¶µÄÊÇ£¬Ëü²¢·Ç×ÜÊÇÄܹ»×öµ½ÕâÒ»µã¡£ÎªÊ²Ã´²»ÄÜÄØ£¬ÄãÈçºÎ²ÅÄܶ©ÕýËüÄØ£¿
static void copy(String src, String dest) throws IOException {
InputStream in = null;
OutputStream out = n ......
¶¯Ì¬´úÀíÊÇÖ¸¿Í»§Í¨¹ý´úÀíÀàÀ´µ÷ÓÃÆäËü¶ÔÏóµÄ·½·¨
¶¯Ì¬´úÀíʹÓó¡ºÏ:
•Ô¶³Ì·½·¨µ÷ÓÃ(RMI)
•
1.´´½¨Ò»¸öʵÏÖ½Ó¿ÚInvocationHandlerµÄÀ࣬Ëü±ØÐëʵÏÖinvoke·½·¨
2.´´½¨±»´úÀíµÄÀàÒÔ¼°½Ó¿Ú
3.ͨ¹ýProxyµÄ¾²Ì¬·½·¨
newProxyInstance(ClassLoader loader, Class[] interfaces, InvocationHandler ......