Java¶ÔÏóת»»XMLÎļþ£ºXStream+XPP
²»ÐèÒªÉú³Édtd,ÎÞÓÃÅäÖÃ,²»ÐèÒªÉú³É¸¨ÖúÀ࣬Ëٶȿ졣Õâ¾ÍÊÇxstream+xpp³¬Ç¿»Æ½ð×éºÏ¡£
xstream´ó¼Ò¶¼ÖªµÀÀ²£¬XML Pull ParserÊÇÒ»ÖÖ¸ßËÙµÄ ½âÎöxmlÎļþµÄ·½Ê½£¬ËÙ¶ÈÒª±È´«Í³·½Ê½¿ìºÜ¶à£¨·¢ÏÖpullʽ½âÎöÏÖÔڱȽÏÁ÷ÐÐÁË£©¡£ÏÂÃæÎÒ¸ø³ö¶àÖÖʹÓ÷½·¨µÄÀý×Ó¡£
1.×î¼òµ¥µÄʹÓ÷½·¨
ÒòΪÕâ¸öÌ«¼òµ¥£¬ËùÒÔÎÒ´ÓmoogleµÄblog http://moogle.javaeye.com/blog/34661È¡ÏÂÃæµÄÀý×Ó
1. public static void write() {
2. XStream sm = new XStream();
3. mytest t = new mytest();
4. t.setName("moogle");
5. t.setXb("ÄÐ");
6. try {
7. FileOutputStream ops = new FileOutputStream(new File("C:\\111.xml"));
8. sm.toXML(t, ops);
9. ops.close();
10. } catch (Exception e) {
11. e.printStackTrace();
12. }
13. }
14. public static void read() {
15. XStream sm = new XStream(new DomDriver());
16. try {
17. FileInputStream ops = new FileInputStream(new File("C:\\111.xml"));
18. mytest t = (mytest)sm.fromXML(ops);
19. System.out.println(t.getName());
20. ops.close();
21.  
Ïà¹ØÎĵµ£º
1.javaµ÷ÓÃcmdÃüÁ
Runtime.getRuntime().exec("taskkill /f /im firefox.exe");
2.ʹÓÃÁËloadProp()·½·¨µ÷ÓÃjar°üÄÚµÄpropertiesÎļþ
ʹÓÃjava³ÌÐò¼à¿ØgeneFTP·þÎñÆ÷(ʹÓÃwindows¼Æ»®ÈÎÎñÖ´ÐÐjar°ü)£¬´úÂëÈçÏÂ:(¹¤³ÌĿ¼½á¹¹¼û¸½¼þ)
Task.java:
package com.monitor;
import java.io.BufferedReader;
import java ......
xmlÓÐʲôÓÅÊƺÍÌصã
“¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ”(XML) ÌṩһÖÖÃèÊö½á¹¹»¯Êý¾ÝµÄ·½·¨¡£ÓëÖ÷ÒªÓÃÓÚ¿ØÖÆÊý¾ÝµÄÏÔʾºÍÍâ¹ÛµÄ
HTML ±ê¼Ç²»Í¬£¬XML ±ê¼ÇÓÃÓÚ¶¨ÒåÊý¾Ý±¾ÉíµÄ½á¹¹ºÍÊý¾ÝÀàÐÍ¡£
XML
ʹÓÃÒ»×é±ê¼ÇÀ´Ãè»æÊý¾ÝÔªËØ¡£Ã¿¸öÔªËØ·â×°¿ÉÄÜÊ®·Ö¼òµ¥Ò²¿ÉÄÜÊ®·Ö¸´ÔÓµÄÊý¾Ý¡£Äú¿ÉÒÔ¶¨ÒåÒ»×éÎÞÏÞÖÆµÄ XML ±ê¼Ç¡£ÀýÈç£ ......
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.*;
import java.io.*;
import java.nio.CharBuffer;
public class RegTest
{
public static void main(String[] args)
{
//¶¨ÒåÒ»¸öÎÄÕÂÁÐ ......