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

¼¸ÖÖ¶ÁÈ¡ÊôÐÔÎļþµÄJAVAʵÏÖ·½Ê½

 
1.ʹÓÃjava.util.PropertiesÀàµÄload()·½·¨
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
2.ʹÓÃjava.util.ResourceBundleÀàµÄgetBundle()·½·¨¡¡¡¡
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
3.ʹÓÃjava.util.PropertyResourceBundleÀàµÄ¹¹Ô캯Êý¡¡
InputStream in = new BufferedInputStream(new FileInputStream(name));
¡¡¡¡ResourceBundle rb = new PropertyResourceBundle(in);
4.ʹÓÃclass±äÁ¿µÄgetResourceAsStream()·½·¨
InputStream in = JProperties.class.getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
5.ʹÓÃclass.getClassLoader()ËùµÃµ½µÄjava.lang.ClassLoaderµÄgetResourceAsStream()·½·¨¡¡
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
6.ʹÓÃjava.lang.ClassLoaderÀàµÄgetSystemResourceAsStream()¾²Ì¬·½·¨
InputStream in = ClassLoader.getSystemResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
²¹³ä
¡¡¡¡
¡¡¡¡ServletÖпÉÒÔʹÓÃjavax.servlet.ServletContextµÄgetResourceAsStream()·½·¨
InputStream in = context.getResourceAsStream(path);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
ÆäÖÐnameΪpropertiesÎļþÃû×Ö.µ«ÎÒÔÚÍøÉÏ·¢ÏÖÓÐÈË˵ҪдpropertiesÎļþµÄ¾ø¶Ô·¾¶,·ñÔò²âÊÔ   ²» ÄÜͨ¹ý.ÎÒûÑéÖ¤¹ý,ÓÐÐËȤµÄÅóÓÑ¿ÉÒÔÊÔÊÔ.
      ¾ÍÎÒ¸öÈ˶øÑÔÎÒÊDZȽÏÆ«ÏòÓõÚ3·½·¨.ÎÒÔÚÍøÉÏÕÒµ½Ò»Æª½éÉܵĸüΪÏêϸµÄÎÄÕÂ,È«ÎÄÈçÏÂ:
ÔÚÉè¼Æʱ£¬ÎÒÃÇÍùÍùÐèÒª·ÃÎÊһЩÊʺϱ¾µØÐ޸ĵÄÅäÖÃÐÅÏ¢£¬Èç¹û×÷Ϊ¾²Ì¬±äÁ¿£¬ÄÇôÿ´ÎÐ޸Ķ¼ÐèÒªÖØбàÒëÒ»¸öclass£¬.config±£´æ´ËÀàÐÅÏ¢²¢²»Êʺϣ¬ÕâʱÎÒÃÇÐèÒªResourceBundle¡£
   ͨ¹ýResourceBundle£¬ÎÒÃÇÐèÒª·ÃÎÊλÓÚ/WEB-INF/classesĿ¼ÏµÄÒ»¸öºó׺ÃûΪpropertiesµÄÎı¾ÀàÐÍÎļþ£¬´ÓÀïÃæ¶ÁÈ¡ÎÒÃÇÐèÒªµÄÖµ¡£
Locale locale = Locale.getDefault();
    ResourceBundle localResource = ResourceBundle.getBundle("ConnResource", locale);
    String value = lo


Ïà¹ØÎĵµ£º

javaÈëÃÅ

 Javaѧϰ´ÓÈëÃŵ½¾«Í¨ 
Ò»¡¢ JDK (Java Development Kit) 
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......

JavaѹËõÀà¿âµÄʹÓà 2.JDKÖеĴò°ü¡¢Ñ¹ËõÀà¿â

¡¡¡¡inkfishÔ­´´£¬ÇëÎðÉÌÒµÐÔÖÊתÔØ£¬×ªÔØÇë×¢Ã÷À´Ô´£¨http://blog.csdn.net/inkfish£©¡£
¡¡¡¡ÕâÀïºöÂÔÁËjar£¬ÒòΪjarʵÖÊÉÏÊôÓÚzipѹËõ¡££¨À´Ô´£ºhttp://blog.csdn.net/inkfish£©
JDK ZLIBѹËõ£º£¨À´Ô´£ºhttp://blog.csdn.net/inkfish£©
package study.inkfish.compress;
import java.io.BufferedInputStream;
import ......

JavaѹËõÀà¿âµÄʹÓà 3.Apache AntÖеĴò°ü¡¢Ñ¹ËõÀà¿â

¡¡¡¡inkfishÔ­´´£¬ÇëÎðÉÌÒµÐÔÖÊתÔØ£¬×ªÔØÇë×¢Ã÷À´Ô´£¨http://blog.csdn.net/inkfish£©¡£
¡¡¡¡ÕâÀïÐèÒª¹Ø×¢µÄÊÇBZIP2¸ñʽ£¬¾­¹ý²âÊÔ£¬×ÜÊÇÎÞ·¨ÕýȷѹËõ£¬Ô­Òòδ֪£¬¶øapache commons bzip2¸ñʽµÄÎļþѹËõÕý³£¡££¨À´Ô´£ºhttp://blog.csdn.net/inkfish£©
Ant ZIPѹËõ£º£¨À´Ô´£ºhttp://blog.csdn.net/inkfish£©
package stu ......

JavaѹËõÀà¿âµÄʹÓà 5.ÐÔÄܼì²â

¡¡¡¡inkfishÔ­´´£¬ÇëÎðÉÌÒµÐÔÖÊתÔØ£¬×ªÔØÇë×¢Ã÷À´Ô´£¨http://blog.csdn.net/inkfish
£©¡£
¡¡¡¡ÔÚÑ¡ÔñѹËõ¡¢´ò°üËã·¨µÄʱºò£¬²»½ö½öҪѡÔñËã·¨£¬»¹ÐèҪѡÔñÓÃÄĸöʵÏÖÀà¿â£¬²»Í¬µÄʵÏÖÀà¿âʵÏÖЧÂʲ»Í¬£¬Ä¬ÈÏѹËõ±ÈÂʲ»Í¬¡£ÎªÁ˲âÊÔJDK¡¢Ant¡¢commons-compressÔÚĬÈÏÇé¿öϵÄЧÂÊ£¬Éè¼ÆÁËÈçϳÌÐò£º£¨À´Ô´£ºhttp://blog.c ......

JAVAѧϰ֮·

 ¡¡ ¡¡¡¡
¡¡¡¡Èí¼þ¿ª·¢Ö®Â·ÊdzäÂú¾£¼¬ÓëÌôս֮·,Ò²ÊdzäÂúÏ£Íû֮·¡£JAVAѧϰҲÊÇÈç´Ë£¬Ã»Óнݾ¶¿É×ß¡£ÃÎÏëÏñ¡¶ÌìÁú°Ë²¿¡·ÖÐÐéÖñÒ»Ñù±»ÎÞÑÂ×Óõ®õ­¹à¶¥¶øÇáËÉ»ñµÃÒ»¼××Ó¹¦Á¦£¬ÊǺܲ»ÏÖʵµÄ¡£Ã¿ÌìÑöÌì´ó½Ð"ÌìÉñ°¡£¬Çë´Í¸øÎÒÒ»±¾¿û»¨±¦µä°É"£¬Êâ²»Öª¼´Ê¹Äã»ñµÃÁË¿û»¨±¦µä£¬³ýÁËÊÜ×Ô¹¬ÆäÉíÖ®¿àÍ⣬ÄãÒ²²»Ò»¶¨³ÉµÃÁË"¶«·½² ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ