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ÏÂÃ棬ÀïÃæ°üº¬ÊýÄ¿ÖÚ¶à ......
javaÓïÑÔÊǽâÊÍÖ´ÐУ¬javaÔ´ÂëÊÇͨ¹ý±àÒëÉú³ÉÒ»ÖÖÌØÊâµÄ.classµÄÖмä×Ö½âÂëÎļþ£¬È»ºóÔÙÓÐJVM½øÐнâÊÍÖ´ÐС£
javaÓïÑÔ¶ÔÖ¸Õë½øÐÐÁËÉϲãµÄ·â×°£¬Ëü±£Ö¤Äܹ»Í¨¹ýÕâ¸öÖ¸Õ루ÒýÓã©£¬À´·ÃÎÊÓÐЧµÄÄÚ´æµ¥Ôª¡£
javaÓïÑÔ²»ÔÊÐí¶à¼Ì³Ð£¬Ê¹¼Ì³Ð¹Øϵ³ÉÊ÷װͼ£¬Ã¿¸öÀ඼ֻÄÜÓÉÒ»¸ö¸¸Àà¡£
javaÓïÑԵĿª·¢Ð§Âʸߣ¬µ«Ö´ÐÐЧÂʵ͡££¨Ïൠ......
ÔÚÀàÖж¨ÒåµÄ·½·¨ÔÚ·µ»Øֵǰ¼ÓÉÏstaticÐÞÊηû¾Í¿ÉÒÔÔÚmain·½·¨Öе÷ÓÃÁË¡£Èç¹û²»ÓÃstaticÄǾÍÐèÒªÔÚmain·½·¨Öд´½¨¶ÔÏó£¬Ê¹ÓöÔÏóÀ´µ÷ÓöÔÏóµÄ·½·¨¡£
public class Test{
public static void main(String[] args){
Test t=new Test();
int b=1;
int c=2;
int[] ......
ÃæÏò¶ÔÏóµÄ˼Ïë
anything is Object£¨ÍòÎï½Ô¶ÔÏó£©
³éÏ󣬴ӶԾßÌåµÄ¶ÔÏóÖгéÈ¡ÓÐÓÃÐÅÏ¢¡£
¶ÔÏóÓÐÆä¹ÌÓÐÊôÐÔ£¬¶ÔÏóµÄ·½·¨£¬¼´¶ÔÏóµÄÐÐΪ£¨¶ÔÏóÄÜ×öʲô£©
¶ÔÏó±¾ÉíÊǼòµ¥µÄ£¨¹¦Äܼòµ¥£©£¬¶à¸ö¶ÔÏó¿ÉÒÔ×é³É¸´ÔÓµÄϵͳ£¨¶ÔÏóÖ®¼ä±Ë´Ëµ÷ÓöԷ½µÄ·½·¨£©
¶ÔÏóÓ¦µ±ÊǸ÷˾ÆäÖ°£¨¹¦Äܼòµ¥£©£¬¸÷¾¡ËùÄÜ£¨°Ñ×Ô¼ºµÄ¹¦ÄÜ×÷µ½×îºÃ£© ......
Ò»¸öÓÅÐãµÄjava±à³Ì³ÌÐòÔ±±ØÐëÁ˽âGCµÄ¹¤×÷ÔÀí¡¢ÈçºÎÓÅ»¯GCµÄÐÔÄÜ¡¢ÈçºÎÓëGC½øÐÐÓÐÏ޵Ľ»»¥£¬ÒòΪÓÐһЩӦÓóÌÐò¶ÔÐÔÄÜÒªÇó½Ï¸ß£¬ÀýÈçǶÈëʽϵͳ¡¢ÊµÊ±ÏµÍ³µÈ£¬Ö»ÓÐÈ«ÃæÌáÉýÄÚ´æµÄ¹ÜÀíЧÂÊ £¬²ÅÄÜÌá¸ßÕû¸öÓ¦ÓóÌÐòµÄÐÔÄÜ¡£±¾ÆªÎÄÕÂÊ×Ïȼòµ¥½éÉÜGCµÄ¹¤×÷ÔÀíÖ®ºó£¬È»ºóÔÙ¶ÔGCµÄ¼¸¸ö¹Ø¼üÎÊÌâ½øÐÐÉîÈë̽ÌÖ£¬×îºóÌá³öһЩjava± ......