Properties file - The reader class

Now we we need a PropertyReader class that would help us read the property values.

Consider the following code for reading the properties. Add this class under the util package.

public class PropertyReader {

    Properties properties = new Properties();
    InputStream inputStream = null;

    public PropertyReader() {

    private void loadProperties() {
        try {
            inputStream = new FileInputStream("src/");
        } catch (IOException e) {

    public String readProperty(String key) {
        return properties.getProperty(key);

Important points to note in the property reader class.

  • Whenever a new instance of this class is created, all the properties would be loaded.
  • readProperty() method would be used by implementers to read a property value.

results matching ""

    No results matching ""