易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

HTML调用XML数据实例

文章转自【PHP探路者】
XML 应用于 web 开发的许多方面,常用于简化数据的存储和共享。
如果需要在 HTML 文档中显示动态数据,那么每当数据改变时将花费大量的时间来编辑 HTML,
XML 可以把数据从 HTML 中分离开来。
通过 XML,数据能够存储在独立的 XML 文件中。这样你就可以专注于使用 HTML 进行布局和显示,并确保修 ......

四眼看世界 XML语法


XML (EXtensible Markup Language)
XML is a
cross-platform, software and hardware independent tool for transmitting
information.
Prolog
XML
Declaration
Processing
Instructions
DOCTYPE
Declaration
Elements
Attributes
XML
Comments
CDATA
Sections
Character
and Entity Refere ......

XML的简单读取与写入

已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price>
</book>
</booksto ......

XML解析方法讲解

XML现在已经成为一种通用的数据交换格式,它的平台无关性,语言无关性,系统无关性,给数据集成与交互带来了极大的方便。对于XML本身的语法知识与技术细节,需要阅读相关的技术文献,这里面包括的内容有DOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Exten ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号