¼¸ÖÖ¶ÁÈ¡ÊôÐÔÎļþµÄJAVAʵÏÖ·½Ê½
1.ʹÓÃjava.util.PropertiesÀàµÄload()·½·¨
¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡2.ʹÓÃjava.util.ResourceBundleÀàµÄgetBundle()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
¡¡¡¡
¡¡¡¡3.ʹÓÃjava.util.PropertyResourceBundleÀàµÄ¹¹Ô캯Êý¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = new BufferedInputStream(new FileInputStream(name));
¡¡¡¡ResourceBundle rb = new PropertyResourceBundle(in);
InputStream in = new BufferedInputStream(new FileInputStream(name));
¡¡¡¡ResourceBundle rb = new PropertyResourceBundle(in);
¡¡¡¡
¡¡¡¡4.ʹÓÃclass±äÁ¿µÄgetResourceAsStream()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = JProperties.class.getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = JProperties.class.getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡5.ʹÓÃclass.getClassLoader()ËùµÃµ½µÄjava.lang.ClassLoaderµÄgetResourceAsStream()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡6.ʹÓÃjava.lang.ClassLoad
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔǰ£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
/*
* CookieSupport.java
* Copyright (C) 2007-3-19 <JustinLei@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version ......
ÔÚjavaÓïÖÐGC
¼´À¬»øÊÕ¼¯»úÖÆÊÇÖ¸jvmÓÃÓÚÊÍ·ÅÄÇЩ²»ÔÙʹÓõĶÔÏóËùÕ¼ÓõÄÄÚ´æ¡£javaÓïÑÔ²¢²»ÒªÇójvmÓÐgc£¬Ò²Ã»Óй涨gcÈçºÎ¹¤×÷¡£²»¹ý³£ÓõÄjvm¶¼ÓÐgc£¬¶øÇÒ´ó¶àÊýgc¶¼Ê¹ÓÃÀàËÆµÄËã·¨¹ÜÀíÄÚ´æºÍÖ´ÐÐÊÕ¼¯²Ù×÷¡£
À¬»øÊÕ¼¯µÄÄ¿µÄÔÚÓÚÇå³ý²»ÔÙʹÓõĶÔÏó¡£gcͨ¹ýÈ·¶¨¶ÔÏóÊÇ·ñ±»»î¶¯¶ ......
java.lang.NullPointerException
Õâ¸öÒì³£´ó¼Ò¿Ï¶¨¶¼¾³£Óöµ½£¬Òì³£µÄ½âÊÍÊÇ "³ÌÐòÓöÉÏÁË¿ÕÖ¸Õë "£¬¼òµ¥µØËµ¾ÍÊǵ÷ÓÃÁËδ¾³õʼ»¯µÄ¶ÔÏó»òÕßÊDz»´æÔڵĶÔÏó£¬Õâ¸ö´íÎó¾³£³öÏÖÔÚ´´½¨Í¼Æ¬£¬µ÷ÓÃÊý×éÕâЩ²Ù×÷ÖУ¬±ÈÈçͼƬδ¾³õʼ»¯£¬»òÕßͼƬ´´½¨Ê±µÄ·¾¶´íÎóµÈµÈ¡£¶ÔÊý×é²Ù×÷ÖгöÏÖ¿ÕÖ¸Õ룬ºÜ¶àÇé¿öÏÂÊÇһЩ¸Õ¿ªÊ¼Ñ§Ï°±à³Ì ......
ÔÚÏîÄ¿ÖУ¬ÎÒÃǺܶ඼Óõ½ÁËxmlÎļþ£¬ÎÞÂÛÊDzÎÊýÅäÖû¹ÊÇÓëÆäËüϵͳµÄÊý¾Ý½»»¥¡£
½ñÌì¾ÍÀ´½²Ò»ÏÂJava ÖÐʹÓÃdom4jÀ´²Ù×÷XMLÎļþ¡£
ÎÒÃÇÐèÒªÒýÈëµÄ°ü£º
//Îļþ°ü
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
//¹¤¾ß°ü
import java.util.Itera ......