Java XStream·â×°Àà
´Ë¸öÀàÊÇΪÁË·½±ã³õѧÕ߶ÔXMLµ½ javabean µÄÏ໥ת»»²»ÊìϤ¶øдµÄ:
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class XmlBean {
/*
* @AUTHOR:ZHONG
* @CREATETIME:2010/02/10
* @PREAM:OBJECT(JAVABEAN)
* @RETURN:XML STRING
*/
public static String GenerateXML(Object model){
XStream xstream = new XStream(new DomDriver());
//ת»»³É xml ¸ñʽ
String xml = xstream.toXML(model);
return xml;
}
/*
* @AUTHOR:ZHONG
* @CREATETIME:2010/02/10
* @PREAM:STRING(XML)
* @RETURN:(javabean)OBJECT
*/
public static Object fromXML(String xmlString){
XStream xs = new XStream(new DomDriver());
Object ob = xs.fromXML(xmlString);
System.out.println(ob);
return ob;
}
ʹÓÃʵÀý:
public static void main(String[] args) {
UserBean user = new UserBean();
user.setUsername("zhongshulin");
user.setPassword("123456");
user.setEmail("zhong@shulin.com");
user.setPhone("123456789");
user.setAddress("Ö麣ƷÉÐ");
String xml = GenerateXML(user);
user =(UserBean)fromXML(xml);
String userName = user.getUsername();
String pass = user.getPassword();
String email = user.getEmail();
String phone = user.getPhone();
String address = user.getAddress();
}
Ïà¹ØÎĵµ£º
¢Ù¼Ì³ÐTimerTask£¬ÖØдrun·½·¨
package bamboo.task;
import java.util.TimerTask;
public class TimeTaskTest extends TimerTask{
@Override
public void run() {
System.out.println("hi");
}
}
¢Úͨ¹ýtimerÀ´ÉèÖÃij¸öʱ¼äÀ´µ÷Ó㬻òÕßÊÇÏà¸ô¶à³¤Ê±¼äµ÷ÓÃ
package bamboo.test;
......
JAVAµÄÐòÁл¯API£¬ËüÌṩÁËÒ»¸ö¿ò¼Ü£¬ÓÃÀ´½«¶ÔÏó±àÂë³ÉÒ»¸ö×Ö½ÚÁ÷£¬ÒÔ¼°´Ó×Ö½ÚÁ÷±àÂëÖÐÖØй¹½¨¶ÔÏó¡£½«Ò»¸ö¶ÔÏó±àÂë³ÉÒ»¸ö×Ö½ÚÁ÷£¬Õâ¸öÊÇÐòÁл¯¹ý³Ì£¬·´¹ýÀ´¾ÍÊÇ·¹ÐòÁл¯¡£Ò»µ©Ò»¸ö¶ÔÏó±»ÐòÁл¯ºó£¬ÔòËüµÄ±àÂë¿ÉÒÔ´ÓÒ»¸öÕýÔÚÔËÐеÄÐéÄâ»ú±»´«µÝµ½ÁíÍâÒ»¸öÐéÄâ»úÉÏ£¬»òÕß±»´æ´¢ÔÚ´ÅÅÌÉÏ£¬¹©ÒÔºó·´ÐòÁл¯Ê¹Óá£ÐòÁл¯¼¼ÊõÎªÔ ......
Ò»°ãʹÓÃsocket½¨Á¢µÄÁ¬½Ó¶¼ÊôÓÚTCPÁ¬½ÓµÄģʽ..¾ÍÊÇÒ»°ãҪͨ¹ýÈý´ÎÎÕÊÖÀ´½¨Á¢session..È»ºóÔÙ´«ËÍÊý¾Ý..
¶øUDPģʽ²»Í¬µÄµØ·½ÔÚÓÚ..Ëü²»ÐèÒª½¨Á¢ºÍËûÈ˵ÄÁ¬½Ó..¶øÊÇÖ±½ÓÍùһ̨Ö÷»úµÄijһ¸ö¶Ë¿ÚÉÏ·¢ËÍÊý¾Ý±¨ÎÄ..
¶ÔÓÚһЩ¶ÔͨÐÅÖÊÁ¿ÒªÇ󲻸߻òÕß˵Êý¾ÝÏ¡ÊèµÄͨÐÅÀ´Ëµ..ÓÃUDPģʽÊÇÒ»¸ö²»´íµÄÑ¡Ôñ..
ÏÂÃæÊÇÒ»¸öÓÃjavaÊµÏ ......
“JDK1.5”µÄÒ»¸öÖØÒªÖ÷Ìâ¾ÍÊÇͨ¹ýÐÂÔöһЩÌØÐÔÀ´¼ò»¯¿ª·¢£¬ÕâЩÌØÐÔ°üÀ¨·ºÐÍ£¬for-each¡¡Ñ»·£¬×Ô¶¯×°°ü/²ð°ü£¬Ã¶¾Ù£¬¿É±ä²ÎÊý,¡¡¾²Ì¬µ¼Èë¡¡¡£Ê¹ÓÃÕâЩÌØÐÔÓÐÖúÓÚÎÒÃDZàд¸ü¼ÓÇåÎú£¬¾«º·£¬°²È«µÄ´úÂë¡£
Ò»£® Ê×Ïȼòµ¥½éÉÜһϸ÷ÖÖÌØÐÔ¼°ÆäʹÓÃ
1.·ºÐÍ(Generic)
C++ͨ¹ýÄ£°å¼¼Êõ¿ÉÒÔÖ¸¶¨¼¯ºÏµÄÔªËØÀàÐÍ£¬¶øJ ......
ÒýÑÔ
ÓÐJAVA¿ª·¢¾ÑéµÄÅóÓÑÃÇÒ»¶¨Åöµ½¹ýÏÂÃæµÄÕâÖÖÇé¿ö,ÄǾÍÊÇ×Ô¼ºËù¿ª·¢µÄÓ¦ÓÃÔËÐÐÁËÒ»¶Îʱ¼äºóÆäÐÔÄÜ»ò ÕßÏìÓ¦ËٶȻáÓÐÃ÷ÏԵĽµµÍ.ÕâÊÇÓɶ෽ÃæµÄÔÒòÔì³ÉµÄ¼´ÓгÌÐò±¾ÉíµÄÓÅ»¯ÎÊÌâ,Ò²ÓÐÔËÐл·¾³ÎÊÌâ.´ËÔËÐл·¾³¼´°üÀ¨Ó²¼þ»·¾³Ò²°üÀ¨Èí¼þ»·¾³.´ó¶àÊýÈ˵ÚÒ» ¸öÄÜÏëµ½µÄ½â¾ö·½·¨ÊÇÌáÉýÓ²¼þµÄÅäÖöøºöÂÔÁ˳ÌÐò±¾ÉíµÄÔËÐл·¾ ......