Source: http://www.study-code.com/java/j2se/66421.htm
// Use J2SEAPI to read Properties files
// 1. Example of the load () method using the java. util. Properties class:
InputStreamin = lnewBufferedInputStream (newFileInputStream (name ));
Propertiesp = newProperties ();
P. load (in );
// 2. Example of using the getBundle () method of the java. util. ResourceBundle class:
ResourceBundlerb = ResourceBundle. getBundle (name, Locale. getDefault ());
// 3. Example of a constructor using the java. util. PropertyResourceBundle class:
InputStreamin = newBufferedInputStream (newFileInputStream (name ));
ResourceBundlerb = newPropertyResourceBundle (in );
// 4. Example of the getResourceAsStream () method using the class variable:
InputStreamin = JProperties. class. getResourceAsStream (name );
Propertiesp = newProperties ();
P. load (in );
// 5. Example of the getResourceAsStream () method of java. lang. ClassLoader obtained by using class. getClassLoader:
InputStreamin = JProperties. class. getClassLoader (). getResourceAsStream (name );
Propertiesp = newProperties ();
P. load (in );
// 6. Example of using the getSystemResourceAsStream () Static Method of the java. lang. ClassLoader class:
InputStreamin = ClassLoader. getSystemResourceAsStream (name );
Propertiesp = newProperties ();
P. load (in );
// Supplement
// The getResourceAsStream () method of javax. Servlet. ServletContext can be used in servlet as an example:
InputStreamin = context. getResourceAsStream (path );
Propertiesp = newProperties ();
P. load (in );