Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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();
  
 }


Ïà¹ØÎĵµ£º

java ¸ñʽ»¯Êä³ö

Ò»¡¢java.util.Formatter
 
java.util.Formatter ÊÇJDK1.5ÐÂÔöµÄÀà¿â£¬¹¦ÄܺÜÇ¿´ó£¬µ«ÊDz»ºÃÕÆÎÕ£¬¾ÍÏñÏÂÆåÒ»Ñù£¬ÖªµÀÈçºÎ×߯å×Ó£¬ºÍÊìÁ·Ó¦ÓÃÍêÈ«ÊÇÁ½ÂëÊ¡£
 
¸ñʽ»¯Ö÷ÒªÓÃÔÚÎı¾Êä³ö·½Ã棬±ÈÈ磬Êý×Ö¡¢ÈÕÆÚ¡¢½ð¶îµÈ£¬»¹ÓÐÀàËÆ³¬ÊеĹºÎﵥСƱµÈµÈ£¬¶¼»áÓõ½¸ñʽ»¯Êä³öµÄ¹¤¾ß¡£ÔÚ´ËÀàû³öÏÖ֮ǰ£¬Ö»ÄÜͨ¹ý¿ ......

javaÎļþºÍÎļþ¼ÐµÄ²Ù×÷

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µÄÐòÁл¯API£¬ËüÌṩÁËÒ»¸ö¿ò¼Ü£¬ÓÃÀ´½«¶ÔÏó±àÂë³ÉÒ»¸ö×Ö½ÚÁ÷£¬ÒÔ¼°´Ó×Ö½ÚÁ÷±àÂëÖÐÖØÐ¹¹½¨¶ÔÏó¡£½«Ò»¸ö¶ÔÏó±àÂë³ÉÒ»¸ö×Ö½ÚÁ÷£¬Õâ¸öÊÇÐòÁл¯¹ý³Ì£¬·´¹ýÀ´¾ÍÊÇ·¹ÐòÁл¯¡£Ò»µ©Ò»¸ö¶ÔÏó±»ÐòÁл¯ºó£¬ÔòËüµÄ±àÂë¿ÉÒÔ´ÓÒ»¸öÕýÔÚÔËÐеÄÐéÄâ»ú±»´«µÝµ½ÁíÍâÒ»¸öÐéÄâ»úÉÏ£¬»òÕß±»´æ´¢ÔÚ´ÅÅÌÉÏ£¬¹©ÒÔºó·´ÐòÁл¯Ê¹Óá£ÐòÁл¯¼¼ÊõÎªÔ ......

Ò»µÀ¼òµ¥µÄjavaÌ⣬ȷ·ÑÁËÎÒͦ³¤Ê±¼äµÄ¡£

½ñÈÕÔÚÍøÉÏżȻÅöµ½Ò»¸ö³õѧÕßµÄjavaÌâÄ¿£¬¾Í³¢ÊÔµÄ×öÁËһϣ¬µ«Ã»Ïëµ½Ò»×ö¾ÍÊǽӽüÒ»¸öÖÓÍ·°¡£¬¿´À´javaѧϰµÄ·ÉÏ»¹ÊÇ·ÂþÂþÙâÐÞÔ¶°¡¡£
 ÌâÄ¿ÈçÏ£º
±àдһ¸öJava Application ³ÌÐò£¬½ÓÊÜÓû§ÊäÈëµÄÒ»¸ö¸¡µãÊý£¬½«ÆäµÄÕûÊý²¿·ÖºÍСÊý²¿·Ö·Ö±ðÊä³ö¡£
È磺ÊäÈë56.6 £¬ÔòÓÐ
¡¡¡¡¡¡¡¡¡¡¡¡ÕûÊý²¿·Ö£º56
¡¡¡¡¡¡¡¡¡¡¡¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ