java ²Ù×÷XMLÎļþ£¨Æ¬¶Î£©
//create a new Document
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.newDocument();
//add root Node
Element noteuser = d.createElement("note-users");
d.appendChild(noteuser);
//add exists Node
Document readXML = db.parse(new File("c:\\note-user.xml"));
NodeList nl = readXML.getElementsByTagName("user");
for(int i = 0; i < nl.getLength(); i++)
{
Element n = d.createElement("user");
n.setAttribute("name", nl.item(i).getAttributes().getNamedItem("name").getNodeValue());
if(id !=null && id.equals(nl.item(i).getAttributes().getNamedItem("name").getNodeValue()))
{
//duplicate id (redirect to error page)
response.getWriter().print("<font color = red>duplicate id !</font>");
response.getWriter().print(" ");
response.getWriter().print("<a href = \"reg.jsp\">return to login page</a>");
return;
}
n.setAttribute("password", nl.item(i).getAttributes().getNamedItem("password").getNodeValue());
noteuser.appendChild(n);
}
//add regist Node
Element n = d.createElement("user");
n.setAttribute("name", id);
n.setAttribute("password", pwd);
noteuser.appendChild(n);
//save data to file
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(d);
//file's path
StreamResult result = new StreamResult(new File("c:\\note-user.xml"));
transformer.transform(source, resu
Ïà¹ØÎĵµ£º
SunÔÚJava5ÖУ¬¶ÔJavaÏ̵߳ÄÀà¿â×öÁË´óÁ¿µÄÀ©Õ¹£¬ÆäÖÐÏ̳߳ؾÍÊÇJava5µÄÐÂÌØÕ÷Ö®Ò»£¬³ýÁËÏ̳߳ØÖ®Í⣬»¹Óкܶà¶àÏß³ÌÏà¹ØµÄÄÚÈÝ£¬Îª¶àÏ̵߳ıà³Ì´øÀ´Á˼«´ó±ãÀû¡£ÎªÁ˱àд¸ßЧÎȶ¨¿É¿¿µÄ¶àÏ̳߳ÌÐò£¬Ï̲߳¿·ÖµÄÐÂÔöÄÚÈÝÏÔµÃÓÈΪÖØÒª¡£
ÓйØJava5Ïß³ÌÐÂÌØÕ÷µÄÄÚÈÝÈ«²¿ÔÚjava.util.concurrentÏÂÃ棬ÀïÃæ°üº¬ÊýÄ¿ÖÚ¶à ......
1 JAVAµÄ·´Éä,Æäʵ¾ÍÊÇͨ¹ýÒ»¸öʵÀý»¯µÄ¶ÔÏó·´¹ýÀ´È¥ÕÒµ½Ò»¸öÀàµÄÍêÕûÐÅÏ¢,±ÈÈç¶ÔÓÚÈçϵÄÐÎʽ:
X x=new X();
x.getClass().getName();
ÕâÀï¾Í»áÊä³öÕâ¸öÀàËùÔÚµÄÍêÕûÐÅÏ¢,¼´"°üÃû.ÀàÃû";
×î³£ÓõÄÈýÖÖʵÀý»¯CLASSÀà¶ÔÏó
Class<?> c1 = null ; // Ö¸¶¨·ºÐÍ
C ......
Ò»£®MsXml´´½¨XMLÎĵµÊ¾Àý
// XmlCreationDemo.cpp
#include <stdlib.h>
#include <stdio.h>
// ÒýÈëMSXML½âÎöÆ÷
#import <msxml4.dll>
using namespace MSXML2;
class InitializeCom
{
public:
InitializeCom() { CoInitialize(NULL); // Initializes the COM library }
~Initializ ......
±¾ÎÄת×Ôhttp://kingsui.javaeye.com/blog/154712
javaµ¼Èëµ¼³öexcel²Ù×÷(jxl)
Java½âÊÍExcelÊý¾Ý£¨jxl.jar°üµÄʹÓã©
¹Ø¼ü×Ö: java excel jxl.jar
jxl.jar °ü
ÏÂÔصØÖ·:
http://www.andykhan.com/jexcelapi/
ÕæʵÏÂÔصØÖ·:
http://www.andykhan.com/jexcelapi/download.html
ÍøÕ¾É϶ÔËüµÄÌØÕ÷ÓÐÈçÏÂÃèÊö£ ......
private static boolean isValidDate(String strValue ) {//20091001×Ö·û´®
int d = Integer.parseInt(strValue.substring(6, 8));
int m = Integer.parseInt(strValue.substring(4, 6));
int y = Integer.parseInt(strValue.subst ......