Http://www.open-open.com/lib/view/open1400721838050.html
11. Using the Load () method of the Java.util.Properties class2Example: InputStream in = Lnew Bufferedinputstream (NewFileInputStream (name));3Properties p =NewProperties ();4 p.load (in);5 62. Using the Getbundle () method of the Java.util.ResourceBundle class7Example: ResourceBundle RB =resourcebundle.getbundle (name, Locale.getdefault ());8 9 3. Use the constructor of the Java.util.PropertyResourceBundle classTenExample: InputStream in =NewBufferedinputstream (NewFileInputStream (name)); OneResourceBundle RB =NewpropertyResourceBundle (in); A -4. The getResourceAsStream () method using the class variable -Example: InputStream in = jproperties.class. getResourceAsStream (name); theProperties p =NewProperties (); - p.load (in); - -5. The getResourceAsStream () method of Java.lang.ClassLoader obtained using Class.getclassloader () +Example: InputStream in = jproperties.class. getClassLoader (). getResourceAsStream (name); -Properties p =NewProperties (); + p.load (in); A at6. Using the Getsystemresourceasstream () static method of the Java.lang.ClassLoader class -Example: InputStream in =Classloader.getsystemresourceasstream (name); -Properties p =NewProperties (); - p.load (in); - - Supplement in - the getResourceAsStream () method of Javax.servlet.ServletContext can be used in Servlets toExample: InputStream in =context.getresourceasstream (path); +Properties p =NewProperties (); -P.load (in);
Six ways Java reads the properties file