javaÖеĶ¯Ì¬´úÀí
JavaÔÚJDK1.3Ö®ºó¼ÓÈëÁË¿ÉÐÖú¿ª·¢¶¯Ì¬´úÀí¹¦ÄܵÄAPI.ʹÓö¯Ì¬´úÀí£¬¿ÉÒÔʹһ¸ö´¦ÀíÕߣ¨´úÀí£©·þÎñÓÚ¸÷¸ö¶ÔÏó¡£´´½¨Ò»¸ö¶¯Ì¬´úÀíÀàÖ»ÐèʵÏÖjava.lang.reflect.InvocationHandler½Ó¿Ú¡£
ÏÂÃæ´´½¨Ò»¸ö´¦ÀíÈÕÖ¾µÄ¶¯Ì¬´úÀíÀàLogHandlerÈ¥´úÀíHelloSpeakerÀà
Ê×ÏÈ´´½¨HelloSpeakerµÄ½Ó¿Ú
package com.test;
public interface IHello {
public void sayHello(String name);
}
È»ºó´´½¨HelloSeaker
package com.test;
public class HelloSpeaker implements IHello {
public void sayHello(String name) {
System.out.println("hello:"+name);
}
}
×îºó´´½¨LogHandlerÀà
package com.test;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.logging.Logger;
public class LogHandler implements InvocationHandler {
private Logger logger = Logger.getLogger(this.getClass().getName());
private Object delegate;
public Object bind(Object delegate) {
this.delegate = delegate;
return Proxy.newProxyInstance(delegate.getClass().getClassLoader(),
delegate.getClass().getInterfaces(), this);
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
Object result = null;
try {
logger.info("method start..." + method);
result = method.invoke(delegate, args);
logger.info("method end..." + method);
} catch (Exception e) {
logger.info(e.getMessage());
}
return result;
}
}
ºÃÁË£¬ÏÖÔÚÎÒÃDZàдһ¸ö²âÊÔÀàDemo
package com.test;
public class Demo {
public Demo() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
LogHandler logHandler = new LogHandler();
&
Ïà¹ØÎĵµ£º
ÔÎÄÀ´×ÔÓÚ¡¶Developing Games in Java¡·£¬×÷ÕߣºDavid Brackeen, Bret Barker, Laurence Vanhelsuwé
JavaÔÚÉè¼Æʱ³ä·Ö¿¼ÂÇÁËÏß³Ì,Òò´ËÔÚJavaÖÐÏ̵߳IJÙ×÷±ÈÆäËûÓïÑÔÒª¼òµ¥¡£Ö»ÐèÉú³ÉÒ»¸öThreadÀàµÄʵÀý±ã¿É´´½¨Ò»¸öỊ̈߳¬È»ºóµ÷ÓÃstart()·½·¨Ï߳̾ÍÆô¶¯ÁË¡£
&nbs ......
win7ϵͳÏÂJava»·¾³±äÁ¿µÄÅäÖà Jdk°æ±¾Îª1.6
´ò¿ª¿ØÖÆÃæ°å->Óû§ÕÊ»§->¸ü¸ÄÎҵĻ·¾³±äÁ¿
±äÁ¿Ãû£ºJAVA_HOME
±äÁ¿Öµ£ºD:\Program Files\Java\jdk1.6.0_12(ÕâÖ»ÊÇÎÒµÄJDK°²×°Â·¾¶)
±äÁ¿Ãû£ºPath
ÔÚ±äÁ¿ÖµµÄ×îÇ°Ãæ¼ÓÉÏ£º%JAVA_HOME%\bin;£¨ÈôÒѾÓÐPathÏÎÞÐëÁíÍâР......
ÔÚûÓкúõØÑÐÏ°ÃæÏò¶ÔÏóÉè¼ÆµÄÉè¼Æģʽ֮ǰ£¬ÎÒ¶ÔJava½Ó¿ÚºÍJava³éÏóÀàµÄÈÏʶ»¹ÊǺÜÄ£ºý£¬ºÜ²»¿ÉÀí½â¡£
¸ÕѧJavaÓïÑÔʱ£¬¾ÍºÜÄÑÀí½âΪʲôҪÓнӿÚÕâ¸ö¸ÅÄËä˵ÊÇ¿ÉÒÔʵÏÖËùνµÄ¶à¼Ì³Ð£¬¿ÉÒ»¸öÖ»Óз½·¨Ãû£¬Ã»Óз½·¨ÌåµÄ¶«Î÷£¬ÎÒʵÏÖËüÓÖÓÐʲôÓÃÄØ£¿ÎÒ´ÓËüÄÇʲôҲµÃ²»µ½£¬³ýÁËһЩ·½·¨Ãû£¬ÎÒÖ±½ÓÔÚ¾ßÌåÀàÀï¼ÓÈëÕâЩ·½ ......
ËäÈ»Óà Java™ ÓïÑÔ±àдµÄ³ÌÐòÔÚÀíÂÛÉÏÊDz»»á³öÏÖ“ÄÚ´æй©”µÄ£¬µ«ÊÇÓÐʱ¶ÔÏóÔÚ²»ÔÙ×÷Ϊ³ÌÐòµÄÂ߼״̬µÄÒ»²¿·ÖÖ®ºóÈÔÈ»²»±»À¬»øÊÕ¼¯¡£±¾Ô£¬¸ºÔð±£ÕÏÓ¦ÓóÌÐò½¡¿µµÄ¹¤³Ìʦ Brian Goetz ̽ÌÖÁËÎÞÒâʶµÄ¶ÔÏó±£ÁôµÄ³£¼ûÔÒò£¬²¢Õ¹Ê¾ÁËÈçºÎÓÃÈõÒýÓöÂסй©¡£
ÒªÈÃÀ¬»øÊÕ¼¯£¨GC£©»ØÊÕ³ÌÐò²»ÔÙʹÓõĶÔÏ󣬶 ......
(ת£ºhttp://blog.csdn.net/alex197963/archive/2008/03/26/2219994.aspx)
1.»ù±¾¸ÅÄîµÄÀí½â
¡¡¡¡¾ø¶Ô·¾¶:¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶,(URLºÍÎïÀí·¾¶)ÀýÈç:
C:xyz est.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶.http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸ö
URL¾ø¶Ô·¾¶.
¡¡¡¡Ïà¶Ô·¾¶:Ïà¶ÔÓëij¸ö» ......