Use J2SE API to read Properties files
1. Use the load () method of java. util. Properties class
Example: InputStream in = lnew BufferedInputStream (new FileInputStream (name ));
Properties p = new Properties ();
P. load (in );
2. Use the getBundle () method of the java. util. ResourceBundle class
Example: ResourceBundle rb = ResourceBundle. getBundle (name, Locale. getDefault ());
3. Use the constructor of the java. util. PropertyResourceBundle class
Example: InputStream in = new BufferedInputStream (new FileInputStream (name ));
ResourceBundle rb = new PropertyResourceBundle (in );
4. Use the getResourceAsStream () method of the class variable
Example: InputStream in = JProperties. class. getResourceAsStream (name );
Properties p = new Properties ();
P. load (in );
5. GetResourceAsStream () method of java. lang. ClassLoader obtained by using class. getClassLoader ()
Example: InputStream in = JProperties. class. getClassLoader (). getResourceAsStream (name );
Properties p = new Properties ();
P. load (in );
6. Use the getSystemResourceAsStream () Static Method of the java. lang. ClassLoader class
Example: InputStream in = ClassLoader. getSystemResourceAsStream (name );
Properties p = new Properties ();
P. load (in );
Supplement
You can use the getResourceAsStream () method of javax. Servlet. ServletContext in servlet.
Example: InputStream in = context. getResourceAsStream (path );
Properties p = new Properties ();
P. load (in );