java¶ÁÈ¡XMLÎļþ
1.¶ÁÈ¡XMLÎļþµÄÀࣺ
public class XMLUtils {
private final String DB_XML_FILE = "/XMLSetting.xml";
public Properties getPropertiesfromXML() {
URL url = XMLUtils.class.getResource(dBXMLFILE);
URI uri;
try {
uri = url.toURI();
InputSource xmlfile = new InputSource(uri.getPath());
MyDefaultHandler handler = new MyDefaultHandler ();
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
parser.parse(xmlfile, handler);
return handler.getProps();
} catch (ParserConfigurationException e) {
System.out.println(e.getMessage());
return null;
} catch (SAXException e) {
System.out.println(e.getMessage());
return null;
} catch (IOException e) {
System.out.println(e.getMessage());
return null;
} catch (URISyntaxException e) {
System.out.println(e.getMessage());
return null;
}
}
}
2.´¦ÀíXMLÎļþµÄÀࣺ
import java.util.Properties;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import com.app.common.Constants;
public class MyDefaultHandler extends DefaultHandler {
private Properties props;
private String key = "";
private StringBuffer value = new StringBuffer();
public MyDefaultHandler() {
props = new Properties();
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
value.append(ch, start, length);
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
props.put(key, value.toString().trim());
}
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
value.delete(0, value.length());
key = attributes.getValue(Constants.KEY);
}
public Properties getProps() {
return this.props;
}
}
3.main£º
import java.util.Properties;
pu
Ïà¹ØÎĵµ£º
/**
* ¶ÑÅÅÐò
*
* */
public void heapSort(double[] a){
double temp;
initCreateHeap(a);
for(int i = a.length - 1; i > 0; i --){
temp = a[0];
a[0] = a[i];
a[i] = temp;
createHeap(a, i, 0);
}
}
/**
* ½«Êý×é¿´³ÉÍêÈ«¶þ²æÊ÷£¬½¨Á¢×î´ó¶Ñ
* */
private ......
1¡¢ÀûÓÃSystem.getProperty()º¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
System.out.println(System.getProperty("user.dir"));//user.dirÖ¸¶¨Á˵±Ç°µÄ·¾¶
2¡¢Ê¹ÓÃFileÌṩµÄº¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
File directory = new File("");//É趨Ϊµ±Ç°Îļþ¼Ð
try{
System.out.println(directory.get ......
package com;
import java.util.*;
public class WhatDay {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(System.currentTimeMillis()));
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
switch (dayOfWeek) {
ca ......
ÔÚ¾¹ýÒ»¶Îʱ¼äµÄÐÝÏ¢Ö®ºó£¬Dennis Sosnoski ÓÖ»ØÀ´ÍƳöÁËËûµÄ
Java ±à³ÌµÄ¶¯Ì¬ÐÔ
ϵ
ÁÐµÄµÚ 5 ²¿·Ö¡£ÄúÒÑÔÚÇ°ÃæµÄÎÄÕÂÖп´µ½ÁËÈçºÎ±àдÓÃÓÚת»» Java ÀàÎļþÒԸıä´úÂëÐÐΪµÄ³ÌÐò¡£ÔÚ±¾ÆÚÖУ¬Dennis½«Õ¹Ê¾ÈçºÎʹÓÃ
Javassist
¿ò¼Ü£¬°Ñת»»Óëʵ¼ÊµÄÀà¼ÓÔØ¹ý³Ì½áºÏÆðÀ´£¬ÓÃÒÔ½øÐÐÁé»îµÄ“¼´Ê±”ÃæÏò·½Ã ......
JavaÈçºÎ²Ù×÷Word, Excel, PDFÎĵµ£¿
http://www.sina.com.cn 2006Äê08ÔÂ23ÈÕ 14:55 ̫ƽÑóµçÄÔÍø
×÷ÕߣºÊ¢ÖÒÁ¼
¡¡¡¡²Î¿¼:
¡¡¡¡http://danadler.com/jacob/
¡¡¡¡http://jakarta.apache.org/poi/
¡¡¡¡http://www.onjava.com/pub/a/onjava/2003/01/22/poi.html
¡¡¡¡http://www.c ......