ʹÓÃJavaµÄ´úÀí»úÖƽøÐÐÈÕÖ¾Êä³ö
ʾÀý´úÂëÈçÏÂ:
//LogProxy.java
package com.gc.action;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
public class LogProxy 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.log(Level.INFO,args[0]+" ¿ªÊ¼ÉóºËÊý¾Ý...");
result = method.invoke(delegate, args);
logger.log(Level.INFO,args[0]+" ÉóºËÊý¾Ý½áÊø...");
}catch(Exception e){
logger.log(Level.INFO,e.toString());
}
return result;
}
}
//TimeBookInterface.java
package com.gc.impl;
//Õë¶Ô½Ó¿Ú±à³Ì
public interface TimeBookInterface {
public void doAuditing(String name);
}
//TimeBook.java
package com.gc.action;
import com.gc.impl.TimeBookInterface;
public class TimeBook implements TimeBookInterface {
//ÉóºËÊý¾ÝµÄÏà¹Ø³ÌÐò
public void doAuditing(String name){
System.out.println("ÉóºË³ÌÐò");
}
}
//TestHelloWorld.java
package com.gc.test;
import com.gc.action.LogProxy;
import com.gc.action.TimeBook;
import com.gc.impl.TimeBookInterface;
public class TestHelloWorld {
public static void main(String[] args){
//ʵÏÖÁ˶ÔÈÕÖ¾ÀàµÄÖØÓÃ
LogProxy logProxy = new LogProxy();
TimeBookInterface timeBookProxy = (TimeBookInterface
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
WindowsÏÂJAVAÓõ½µÄ»·¾³±äÁ¿Ö÷ÒªÓÐ3¸ö£¬JAVA_HOME¡¢CLASSPATH¡¢PATH¡£ÏÂÃæÖð¸ö·ÖÎö¡£
JAVA_HOMEÖ¸ÏòµÄÊÇJDKµÄ°²×°Â·¾¶£¬Èçx:\JDK_1.4.2£¬ÔÚÕâ·¾¶ÏÂÄãÓ¦¸ÃÄܹ»ÕÒµ½bin¡¢libµÈĿ¼¡£ÖµµÃÒ»ÌáµÄÊÇ£¬JDKµÄ°²×°Â·¾¶¿ÉÒÔÑ¡ÔñÈÎÒâ´ÅÅÌĿ¼£¬²»¹ý½¨ÒéÄã·ÅµÄĿ¼²ã´Îdzһµã£¬Èç¹ûÄã·ÅµÄĿ¼ºÜÉ±ÈÈçx:\XXXXXX\xxxxx\XXXX\xxxx ......
Javaѧϰ·¾¶£¨Ò»£©¹¤¾ßƪ
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJDKÊÇSun¹«Ë¾·¢²¼µÄJDK£¬³ýÁËSunÖ®Í⣬»¹Óкܶ๠......
ITree
package utility.structure.def;
/**
*
* @author odie.tang
*
* @version 1.0 10/30/09
*/
public interface ITree<E>{
E getData();
E remove();
void setData(E e);
int getDepth();
int getLevel();
ITree<E> getRoot();
ITree<E> get ......
package cf.java.study.java.io;
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class FileTests {
@Before
public void set ......