¹ØÓÚJava¶ÁÈ¡xmlÎļþµÄѧϰ
Ò».javaÀà
package com.java.test;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
public class JavaReadXml {
// Document¿ÉÒÔ¿´×÷ÊÇXMLÔÚÄÚ´æÖеÄÒ»¸ö¾µÏñ,ÄÇôһµ©»ñÈ¡Õâ¸öDocument ¾ÍÒâζ×Å¿ÉÒÔͨ¹ý¶Ô
// ÄÚ´æµÄ²Ù×÷À´ÊµÏÖ¶ÔXMLµÄ²Ù×÷,Ê×ÏȵÚÒ»²½»ñÈ¡XMLÏà¹ØµÄDocument
private Document doc = null;
public void init(String xmlFile) throws Exception {
// ºÜÃ÷ÏÔ¸ÃÀàÊÇÒ»¸öµ¥Àý,ÏÈ»ñÈ¡²úÉúDocumentBuilder¹¤³§
// µÄ¹¤³§,ÔÚͨ¹ýÕâ¸ö¹¤³§²úÉúÒ»¸öDocumentBuilder,
// DocumentBuilder¾ÍÊÇÓÃÀ´²úÉúDocumentµÄ
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// Õâ¸öDocument¾ÍÊÇÒ»¸öXMLÎļþÔÚÄÚ´æÖеľµÏñ
doc = db.parse(new File(xmlFile));
}
// ¸Ã·½·¨¸ºÔð°ÑXMLÎļþµÄÄÚÈÝÏÔʾ³öÀ´
public void viewXML(String xmlFile) throws Exception {
this.init(xmlFile);
// ÔÚxmlÎļþÀï,Ö»ÓÐÒ»¸ö¸ùÔªËØ,ÏȰѸùÔªËØÄóöÀ´¿´¿´
Element element = doc.getDocumentElement();
System.out.println("¸ùÔªËØΪ:" + element.getTagName());
NodeList nodeList = doc.getElementsByTagName("person");
System.out.println("book½ÚµãÁ´µÄ³¤¶È:" + nodeList.getLength());
Node fatherNode = nodeList.item(0);
System.out.println("¸¸½ÚµãΪ:" + fatherNode.getNodeName());
// °Ñ¸¸½ÚµãµÄÊôÐÔÄóöÀ´
NamedNodeMap attributes
Ïà¹ØÎĵµ£º
JAVA×¢ÊÍ·½·¨¼°¸ñʽ
1¡¢µ¥ÐÐ(single-line)--¶Ì×¢ÊÍ£º//……
µ¥¶ÀÐÐ×¢ÊÍ£ºÔÚ´úÂëÖе¥ÆðÒ»ÐÐ×¢ÊÍ£¬ ×¢ÊÍÇ°×îºÃÓÐÒ»ÐпÕÐУ¬²¢ÓëÆäºóµÄ´úÂë¾ßÓÐÒ»ÑùµÄËõ½ø²ã¼¶¡£Èç¹ûµ¥ÐÐÎÞ·¨Íê³É£¬ÔòÓ¦²ÉÓÿé×¢ÊÍ¡£
×¢Ê͸ñʽ£º/* ×¢ÊÍÄÚÈÝ */
ÐÐÍ·×¢ÊÍ£ºÔÚ´úÂëÐеĿªÍ·½øÐÐ×¢ÊÍ¡£Ö÷ҪΪÁËʹ¸ÃÐд ......
Java Applet ÊÇÓÃJava ÓïÑÔ±àдµÄһЩСӦÓóÌÐò£¬ÕâЩ³ÌÐòÊÇÖ±½ÓǶÈëµ½Ò³ÃæÖУ¬ÓÉÖ§³ÖJavaµÄä¯ÀÀÆ÷£¨IE »ò Nescape£©½âÊÍÖ´ÐÐÄܹ»²úÉúÌØÊâЧ¹ûµÄ³ÌÐò¡£Ëü¿ÉÒÔ´ó´óÌá¸ßWebÒ³ÃæµÄ½»»¥ÄÜÁ¦ºÍ¶¯Ì¬Ö´ÐÐÄÜÁ¦¡£°üº¬AppletµÄÍøÒ³±»³ÆΪJava-poweredÒ³£¬¿ÉÒÔ³ÆÆäΪJavaÖ§³ÖµÄÍøÒ³¡£
µ±Óû§·ÃÎÊÕâÑùµÄÍøҳʱ£¬Ap ......
1.JavaѧϰÍøÕ¾:
JavaÖÐÎÄÊÀ½çÂÛ̳ http://www.chinajavaworld.com/index.jspa
JavaÊÀ¼ÍÍø http://www.java2000.net/
Java ÖÐÎÄÕ¾ http://www.java-cn.com/
JavaѧϰÊÒ ......
µÚÒ»£¬Ì¸Ì¸final, finally, finalizeµÄÇø±ð¡£
¡¡final ÓÃÓÚÉùÃ÷ÊôÐÔ£¬·½·¨ºÍÀ࣬·Ö±ð±íʾÊôÐÔ²»¿É±ä£¬·½·¨²»¿É¸²¸Ç£¬À಻¿É¼Ì³Ð¡£finallyÊÇÒì³£´¦ÀíÓï¾ä½á¹¹µÄÒ»²¿·Ö£¬±íʾ×ÜÊÇÖ´ÐС£finalizeÊÇ ObjectÀàµÄÒ»¸ö·½·¨£¬ÔÚÀ¬»øÊÕ¼¯Æ÷Ö´ÐеÄʱºò»áµ÷Óñ»»ØÊÕ¶ÔÏóµÄ´Ë·½·¨£¬¿ÉÒÔ¸²¸Ç´Ë·½·¨ÌṩÀ¬»øÊÕ¼¯Ê± ......
×Ô¶¨ÒåµÄKeyÀàÐèÒªÖØÔØequals, hashCodeº¯Êý¡£¡£
package com.albert.test;
import java.util.Vector;
import java.util.HashMap;
/**
* @author tough_guy
*
*/
//¶ÔÓÚ×Ô¶¨ÒåµÄkey£¬ ÐèÒªÖØÔØhashCodeº¯ÊýºÍequalsº¯Êý
class IPSegment
{
long ip_s;
long ip_e;
int p;
IPSegment Reset(long f ......