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
Ïà¹ØÎĵµ£º
Ò»¡¢final
¡¡¸ù¾Ý³ÌÐòÉÏÏÂÎÄ»·¾³£¬Java¹Ø¼ü×ÖfinalÓГÕâÊÇÎÞ·¨¸Ä±äµÄ”»òÕß“ÖÕ̬µÄ”º¬Ò壬Ëü¿ÉÒÔÐÞÊηdzéÏóÀà¡¢·Ç³éÏóÀà³ÉÔ±·½·¨ºÍ±äÁ¿¡£Äã¿ÉÄܳöÓÚÁ½ÖÖÀí½â¶øÐèÒª×èÖ¹¸Ä±ä£ºÉè¼Æ»òЧÂÊ¡£
finalÀ಻Äܱ»¼Ì³Ð£¬Ã»ÓÐ×ÓÀ࣬finalÀàÖеķ½·¨Ä¬ÈÏÊÇfinalµÄ¡£
final·½·¨²»Äܱ»×ÓÀàµÄ·½·¨¸²¸Ç£¬µ«¿ÉÒ ......
1¡¢ÀûÓÃSystem.getProperty()º¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
System.out.println(System.getProperty("user.dir"));//user.dirÖ¸¶¨Á˵±Ç°µÄ·¾¶
2¡¢Ê¹ÓÃFileÌṩµÄº¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
File directory = new File("");//É趨Ϊµ±Ç°Îļþ¼Ð
try{
System.out.println(directory.get ......
ÕâÒ»ÓÐ¹Ø Java ±à³Ì¶¯Ì¬·½ÃæµÄеÄϵÁÐÎÄÕÂÑо¿ÁËÖ´ÐÐ Java Ó¦ÓóÌÐòʱĻºóËù·¢ÉúµÄÊÂÇé¡£ÆóÒµ Javaר¼Ò
Dennis Sosnoski ÌṩÁË Java ¶þ½øÖÆÀà¸ñʽÒÔ¼°ÔÚ JVM
ÄÚ²¿ÀàËù·¢ÉúµÄÇé¿öµÄÄÚÄ»¡£½Ó×Å£¬Ëû½«ÌÖÂÛÀà×°ÈëÎÊÌ⣬Æä·¶Î§Éæ¼°´ÓÔËÐмòµ¥µÄ Java Ó¦ÓóÌÐòËùÐèµÄÀàµÄÊýÁ¿µ½¿ÉÄÜÔì³É J2EE
¼°ÀàËÆµÄ¸´ÔÓÌåϵ½á¹¹³öÏÖÎÊÌâµÄ ......
´ÓJAVAÖ±½Ó¶ÁÈ¡EXCEL¡¢WORD²¢Éú³ÉPDFÎļþ
1¡£²Ù×÷EXCELºÍWORDÎļþ
ʹÓÃJAVA´ÓEXCEL¡¢WORDÎļþÖжÁдÊý¾Ý£¬¿ÉÒÔʹÓÃhttp://jexcelapi.sourceforge.net/
ÌṩµÄJAVA API£Java Excel API£¬ÕâÀïÓÐÆäÖ¸ÄÏhttp://www.andykhan.com/jexcelapi/tutorial.html
£¬¿ÉÓÉ´ËÏÂÔØJARÎļþhttp://www.andykhan.com/jexcelapi/download.h ......
Java¼¯ÈºÖ®session¹²Ïí½â¾ö·½°¸
À´Ô´£ºhttp://blog.csdn.net/crskyp/archive/2009/11/19/4836685.aspx
Ëæ×Å»¥ÁªÍøµÄÈÕÒæ×³´ó,ÍøÕ¾µÄpvºÍuv³ÉÏßÐÔ»òÕßÖ¸Êý±¶µÄÔö¼Ó.µ¥·þÎñÆ÷µ¥Êý¾Ý¿âÔçÒѾ²»ÄÜÂú×ãʵ¼ÊÐèÇó.±ÈÈçÏñÊ¢´ó,ÌÔ±¦ÕâÑùµÄ´óÐÍÍøÂ繫˾,¸üÊÇÈç´Ë.
¼¯Èº,Ò²¾ÍÊÇÈÃÒ»×鼯Ëã»ú·þÎñÆ÷Ðͬ¹¤×÷ ......