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

java 自己做的对XML文件的读写操作

XML文件实例:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource auth="Container" maxActive="20" name="sss" password="123"
type="javax.sql.DataSource" />
<Resource auth="Container" maxActive="20" password="9003"
type="javax.sql.DataSource" />
<Resource as="nnnnnnnnnnnn" name="jdbc/sqlserver-database" />
</Context>

Java类:
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.metadata.IIOMetadataNode;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sun.org.apache.xerces.internal.dom.AttrNSImpl;
import com.sun.org.apache.xerces.internal.impl.xs.opti.DefaultNode;
public class T2 {
/**
* 将修改的内容添加到xml文件中
*
* @param document
* @param filename
* @return
*/
public static boolean doc2XmlFile(Document document, String filename) {
boolean flag = true;
try {
/** 将document中的内容写入文件中 */
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
/** 编码 */
//transformer.setOutputProperty(OutputKeys.ENCODING, "GBK");
DOMSource source = new DOMSource(document);
//判断路径开头有没有“\”如果有则去掉
filename = "C".equals(filename.charAt(0)) ? filename : filename.substring(1);
StreamResult result = new StreamResult(new FileOutputStream(filename));
transformer.transform(source, result);
} catch (Exception ex) {
flag = false;
ex.printStackTrace();
}
r


相关文档:

IBM FileNet Content Java API 简介

2008 年 6 月 24 日
原文地址: http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0806wangys/
本文介绍 IBM FileNet P8 4.0 Platform 提供的 Content Java API。首先对 FileNet P8 Content Engine 和 API 进行概要介绍, 并说明了一些基本概念,随后详细介绍了 FileNet Content Engine提供的基于 EJB ......

“XML DOM读取节点信息”小结

<?
XML DOM读取节点信息遇到问题总结:  
 
1:NodeList: 使用节点的childNodes属性或者document对象的getElementsByTagName()方法,就会返回一个包含节点列表的NodeList
 
2: 在 XML DOM 中,节点的关系被定义为节点的属性:
·  parentNode
·  childNodes
· ......

JAVA连接数据库大全

JAVA连接数据库大全
 
 
1.Oracle8/8i/9i数据库(thin模式)
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:ts"; //ts为数据库的SID
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,u ......

Java 对xml文件的读写操作

/**
* 描述:数据库初始化基本类
*
* @作者 王群
* @创建日期 2010-04-08
* @修改人 xxx
* @修改日期 xxx
* @检查人 xxx
* @检查日期 xxx
*/
import java.sql.SQLException;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.oumasoft.bstmanage.ibatis.SqlMapConfig;
import com.oumasof ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号