Lookup method in DataProvider

We need to build a method in the DataProvider class to look up the messages on the fly using the code passed in to it. We can use a similar method to one created earlier in the utility classes:

/**
* lookupMessage - method to retrieve error messages using code
*
* @param propFilePath - the property file including path
* @param code - the confirmation or error code
* @return String
* @throws Exception
*/
public static String lookupMessage(String propFilePath,
String code)
throws Exception {

Properties props = new Properties();
props.load(new FileInputStream(propFilePath));
String getMsg = props.getProperty(code, null);

if ( getMsg != null ) {
return getMsg;
}

else {
throw new Exception("ERROR: The Code '" + code + "' was not
found!");
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.196.27