xml/propertiesÎļþµÄÏ໥±£´æת»¯
/*
Á·Ï°Ê¹ÓÃjava.util.propertiesÀà°üÀ´²Ù×÷propertes¼°XMLÎļþ,ͨ¹ýstore·½·¨µÄµ÷ÓÿÉʵÏÖxml/propertiesÎļþµÄÏ໥±£´æת»¯
*/
import java.util.*;
import java.io.*;
public class TestPropertes
{
public static void main(String[] args) {
Properties pp = new Properties();
FileInputStream in = null;
FileInputStream xmlin = null;
FileOutputStream out = null;
PrintStream ps=null;
FileOutputStream xmlout =null;
try{
in = new FileInputStream("c:/Test.Properties");
}catch(FileNotFoundException e)
{
System.out.println("propertiesÎļþûÓÐÕÒµ½");
}
try
{
pp.load(in);
}catch(IOException e)
{
System.out.println(e+"µ÷ÓÃload·½·¨Ê±³öÏÖÒì³£");
}
System.out.println(pp.getProperty("log4j.rootLogger"));
System.out.println(pp.getProperty("log4j.appender.A"));
System.out.println(pp.getProperty("log4j.appender.A1.layout"));
try
{
ps = new PrintStream("c:/TestMemo.txt");
out = new FileOutputStream("c:/Test.Properties");
}catch(IOException e1)
{
System.out.println(e1+"PrintStream creat Error");
}
pp.list(ps); //½«propertiesÎļþÓÃlist·½·¨¶ÁÈ¡²¢´æÈëpsÎļþÖÐ
//¸ü¸Ä¼üÖµ
Object o =pp.setProperty("log4j.rootLogger","DEBUG,B"); //¸ü¸Ä¶ÔÓ¦µÄHASHTABLEÖеÄÖµ£¬Êµ¼ÊÉÏÎļþÖеÄֵû±ä»¯
System.out.println(pp.getProperty("log4j.rootLogger"));
pp.list(ps); //½«¼üÖµ¸ü¸ÄºóµÄpropertiesÎļþÓÃlist·½·¨¶ÁÈ¡²¢´æÈëpsÎļþÖÐ.list»á×Ô¶¯ÒÔ×·»ØµÄ·½Ê½´ÓÔÎļþβдÈë
System.out.println(o.getClass());
try
{
&nbs
Ïà¹ØÎĵµ£º
==========================================
xmlÎļþ
£¼?xml version="1.0" encoding="GB2312"?£¾
£¼RESULT£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾A1234£¼/NO£¾
¡¡¡¡ £¼ADDR£¾ËÄ´¨Ê¡XXÏØXXÕòXX·X¶ÎXXºÅ£¼/ADDR£¾
£¼/VALUE£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾B1234£¼/NO£¾
¡¡ ¡¡£¼ADDR£¾ËÄ´¨Ê¡XXÊÐXXÏçXX ......
ÈçºÎ¼ÓÔØÓÐÍâ¹úºÍÌØÊâ×Ö·ûµÄÎĵµ£¿
¡¡¡¡Îĵµ¿ÉÒÔ°üº¬Íâ¹ú×Ö·û£¬ÀýÈ磺
¡¡¡¡foreign characters (úóí?)
¡¡¡¡ÀýÈç íá µÄÍâ¹ú×Ö·û±ØÐëÔÚÇ°Ãæ¼ÓÉÏ escape ÐòÁС£Íâ¹ú×Ö·û¿ÉÒÔÊÇ UTF-8 ±àÂë»òÓò»Í¬±àÂëÖ¸¶¨£¬ÈçÏÂËùʾ£º
¡¡¡¡foreign characters (íá)
¡¡¡ ......
ÔÚ XML ¶ÔÏóÄ£ÐÍÖÐÈçºÎ´¦Àí¿Õ°××Ö·û£¿
¡¡¡¡ÓÐЩʱºò£¬XML ¶ÔÏóÄ£Ðͽ«ÏÔʾ°üº¬¿Õ°××Ö·ûµÄ TEXT ½Úµã¡£¿Õ°××Ö·û±»½Ø¶Ïºó£¬¶à°ë»á´øÀ´Ò»Ð©»ìÂÒ¡£ÀýÈçÏÂÃæµÄ XML Àý×Ó£º
¡¡¡¡]>
¡¡¡¡Smith
¡¡¡¡John
¡¡¡¡Éú³ÉÏÂÁÐÊ÷£º
¡¡¡¡Processing Instruction: xml
¡¡¡¡DocType: person
¡¡¡¡ELEMENT: person ......
ËÄÖÖXML½âÎö·½·¨
xmlÎļþ£º
£¼?xml version="1.0" encoding="GB2312"?£¾
£¼RESULT£¾
£¼VALUE£¾
£¼NO£¾A1234£¼/NO£¾
£¼ADDR£¾ËÄ´¨Ê¡XXÏØXXÕòXX·X¶ÎXXºÅ£¼/ADDR£¾
£¼/VALUE£¾
£¼VALUE£¾
£¼NO£¾B1234£¼/NO£¾
¡¡ ¡¡£¼ADDR£¾ËÄ´¨Ê¡XXÊÐXXÏçXX´åXX×飼/ADDR£¾
£¼/VALUE£¾
£¼/RESULT£¾
1£©DOM
& ......