Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVA¶ÔXMLµÄ¼¸ÖÖ½âÎö·½·¨½²½â£¨JDOM£©

Ϊ¼õÉÙDOM¡¢SAXµÄ±àÂëÁ¿£¬³öÏÖÁËJDOM£»
Óŵ㣺¼«´ó¼õÉÙÁË´úÂëÁ¿¡£
ʹÓó¡ºÏ£ºÒªÊµÏֵŦÄܼòµ¥£¬Èç½âÎö¡¢´´½¨µÈ£¬µ«Ôڵײ㣬JDOM»¹ÊÇʹÓÃSAX£¨×î³£Óã©¡¢DOM¡¢XananÎĵµ¡£
±ØÐëµÃÏÂÔØjdom.jarÎļþ
package xml.jdom;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import xml.XmlDocument;
public class JDomDemo implements XmlDocument {
public static void main(String[] args){
   JDomDemo jDomeDemo = new JDomDemo();
   jDomeDemo.createXml("Test2.xml");
   jDomeDemo.parserXml("Test2.xml");
}
@Override
public void createXml(String fileName) {
   Element root = new Element("employees");
   Document document = new Document(root);
  
   Element employee = new Element("employee");
   root.addContent(employee);
   Element name = new Element("name");
   name.setText("ddvip");
   employee.addContent(name);
   Element sex = new Element("sex");
   sex.setText("m");
   employee.addContent(sex);
   Element age = new Element("age");
   age.setText("23");
   employee.addContent(age);
   XMLOutputter XMLOut = new XMLOutputter();
   try {
    XMLOut.output(document, new FileOutputStream(fileName));
   } catch (FileNotFoundException e) {
    e.printStackTrace();
   } catch (IOException e) {
    e.printStackTrace();
   }
}
@Override
public void parserXml(String fileName) {
   SAXBuilder builder = new SAXBuilder(false);
   try {
    Document document = builder.build(fileName);
    Element employees = document.getRootElement


Ïà¹ØÎĵµ£º

javaÖÐСÊý±£Áô¼°Ê±¼äµÄһЩ²Ù×÷

import java.text.DecimalFormat
double a = 2.3659874;
//СÊý¸ñʽ»¯£¬ÒýºÅÖеÄ0.000±íʾ±£ÁôСÊýµãºóÈý루µÚËÄλËÄÉáÎåÈ룩
DecimalFormat df = new DecimalFormat("0.000");
String num = df.format(a);
System.out.println(num);
Êä³ö½á¹û¾ÍÊÇ 2.366
Java¼ÆËãʱ¼ä²î
±ÈÈ磺ÏÖÔÚÊÇ2004-03-26 13£º31£º40
&nbs ......

java³ÌÐòÔ±±Ø¶ÁÊé¼®

×÷ΪJava³ÌÐòÔ±À´Ëµ£¬×îÍ´¿àµÄÊÂÇéĪ¹ýÓÚ¿ÉÒÔÑ¡ÔñµÄ·¶Î§Ì«¹ã£¬¿ÉÒÔ¶ÁµÄÊéÌ«¶à£¬ÍùÍùÈÝÒ×ÎÞËùÊÊ´Ó¡£ÎÒÏë¾ÍÎÒ×Ô¼º¶Á¹ýµÄ¼¼ÊõÊé¼®ÖÐÌôÑ¡³öÀ´Ò»Ð©£¬°´ÕÕѧϰµÄÏȺó˳Ðò£¬ÍƼö¸ø´ó¼Ò£¬ÌرðÊÇÄÇЩÏë²»¶ÏÌá¸ß×Ô¼º¼¼ÊõˮƽµÄJava³ÌÐòÔ±ÃÇ¡£
Ò»¡¢Java±à³ÌÈëÃÅÀà
¶ÔÓÚûÓÐJava±à³Ì¾­ÑéµÄ³ÌÐòÔ±ÒªÈëÃÅ£¬Ëæ±ã¶ÁʲôÈëÃÅÊé¼®¶¼Ò»Ñù£¬Õâ ......

Java´úÂë±àдµÄ30Ìõ½¨Òé

(1) ÀàÃûÊ××ÖĸӦ¸Ã´óд¡£×ֶΡ¢·½·¨ÒÔ¼°¶ÔÏ󣨾ä±ú£©µÄÊ××ÖĸӦСд¡£¶ÔÓÚËùÓбêʶ·û£¬ÆäÖаüº¬µÄËùÓе¥´Ê¶¼Ó¦½ô¿¿ÔÚÒ»Æ𣬶øÇÒ´óдÖм䵥´ÊµÄÊ××Öĸ¡£ÀýÈ磺
ThisIsAClassName
thisIsMethodOrFieldName
ÈôÔÚ¶¨ÒåÖгöÏÖÁ˳£Êý³õʼ»¯×Ö·û£¬Ôò´óдstatic final»ù±¾ÀàÐͱêʶ·ûÖеÄËùÓÐ×Öĸ¡£ÕâÑù±ã¿É±êÖ¾³öËüÃÇÊôÓÚ±àÒëÆÚµ ......

JavaÖеÄinstanceof¹Ø¼ü×Ö

instanceofÊÇJavaµÄÒ»¸ö¶þÔª²Ù×÷·û£¬ºÍ==£¬>£¬<ÊÇͬһÀණ¶«¡£ÓÉÓÚËüÊÇÓÉ×Öĸ×é³ÉµÄ£¬ËùÒÔÒ²ÊÇJavaµÄ±£Áô¹Ø¼ü×Ö¡£ËüµÄ×÷ÓÃÊDzâÊÔËü×ó±ßµÄ¶ÔÏóÊÇ·ñÊÇËüÓұߵÄÀàµÄʵÀý£¬·µ»ØbooleanÀàÐ͵ÄÊý¾Ý¡£¾Ù¸öÀý×Ó£º
¡¡¡¡String s = "I AM an Object!";
¡¡¡¡boolean isObject = s instanceof Object;
¡¡¡¡ÎÒÃÇÉùÃ÷ÁËÒ»¸öStrin ......

Javaͬ²½»úÖÆ synchronized

²»¾ÃÇ°Óõ½ÁËͬ²½£¬ÏÖÔڻعýÍ·À´¶ÔJAVAÖеÄͬ²½×ö¸ö×ܽᣬÒÔ¶ÔÇ°¶Îʱ¼ä¹¤×÷µÄ×ܽáºÍ×ÔÎÒ¼¼ÊõµÄÌõÀí»°¡£JAVAÖÐsynchronized¹Ø¼ü×ÖÄܹ»×÷Ϊº¯ÊýµÄÐÞÊηû£¬Ò²¿É×÷Ϊº¯ÊýÄÚµÄÓï¾ä£¬Ò²¾ÍÊÇƽʱ˵µÄͬ²½·½·¨ºÍͬ²½Óï¾ä¿é¡£¼ÙÈçÔÙϸµÄ·ÖÀ࣬synchronized¿É×÷ÓÃÓÚinstance±äÁ¿¡¢object reference£¨¶ÔÏóÒýÓã©¡¢staticº¯ÊýºÍclass li ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ