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
相关文档:
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using FilmOnLine.Model;
namespace FilmOnLine.DAL
{
public static class FilmService
{
/// <summary>
/// 添加电影
/// </summary ......
什么是 XML?
可扩展标记语言 (XML) 是 Web 上的数据通用语言。它使开发人员能够将结构化数据,从许多不同的应用程序传递到桌面,进行本地计算和演示。XML 允许为特定应用程序创建唯一的数据格式。它还是在服务器之间传输结构化数据的理想格式。
什么是 MSXML?
MSXML 是提供核心 XML 服务的 Microsoft 软 ......
四种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
& ......