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;
......
/**
* InvokeTester.java
* °æÈ¨ËùÓÐ(C) 2010 cuiran2001@163.com
* ´´½¨:´ÞȽ 2010-2-9 ÏÂÎç02:07:13
*/
package com.timer.demo.objectsocket;
import java.lang.reflect.Method;
/**
* @author ´ÞȽ
*
*/
public class InvokeTester {
public int add(int param1, int param2) {
return param ......
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
im ......
ÒýÑÔ
ÓÐJAVA¿ª·¢¾ÑéµÄÅóÓÑÃÇÒ»¶¨Åöµ½¹ýÏÂÃæµÄÕâÖÖÇé¿ö,ÄǾÍÊÇ×Ô¼ºËù¿ª·¢µÄÓ¦ÓÃÔËÐÐÁËÒ»¶Îʱ¼äºóÆäÐÔÄÜ»ò ÕßÏìÓ¦ËÙ¶È»áÓÐÃ÷ÏԵĽµµÍ.ÕâÊÇÓÉ¶à·½ÃæµÄÔÒòÔì³ÉµÄ¼´ÓгÌÐò±¾ÉíµÄÓÅ»¯ÎÊÌâ,Ò²ÓÐÔËÐл·¾³ÎÊÌâ.´ËÔËÐл·¾³¼´°üÀ¨Ó²¼þ»·¾³Ò²°üÀ¨Èí¼þ»·¾³.´ó¶àÊýÈ˵ÚÒ» ¸öÄÜÏëµ½µÄ½â¾ö·½·¨ÊÇÌáÉýÓ²¼þµÄÅäÖöøºöÂÔÁ˳ÌÐò±¾ÉíµÄÔËÐл·¾ ......
½ñÈÕÔÚÍøÉÏżȻÅöµ½Ò»¸ö³õѧÕßµÄjavaÌâÄ¿£¬¾Í³¢ÊÔµÄ×öÁËһϣ¬µ«Ã»Ïëµ½Ò»×ö¾ÍÊǽӽüÒ»¸öÖÓÍ·°¡£¬¿´À´javaѧϰµÄ·ÉÏ»¹ÊÇ·ÂþÂþÙâÐÞÔ¶°¡¡£
ÌâÄ¿ÈçÏ£º
±àдһ¸öJava Application ³ÌÐò£¬½ÓÊÜÓû§ÊäÈëµÄÒ»¸ö¸¡µãÊý£¬½«ÆäµÄÕûÊý²¿·ÖºÍСÊý²¿·Ö·Ö±ðÊä³ö¡£
È磺ÊäÈë56.6 £¬ÔòÓÐ
¡¡¡¡¡¡¡¡¡¡¡¡ÕûÊý²¿·Ö£º56
¡¡¡¡¡¡¡¡¡¡¡¡ ......