June 2018
Beginner
722 pages
18h 47m
English
The getStringValueFromConfig() method is located in the Utils class, which we have created to read the values from the .conf file. This class has the following code:
import org.json.simple.JSONObject;import org.json.simple.parser.JSONParser;import org.json.simple.parser.ParseException;public class Utils { private static JSONObject config = null; public static String getStringValueFromConfig(String configFileName, String key){ if(config == null){ ClassLoader classLoader = Utils.class.getClassLoader(); File file = new File(classLoader.getResource(configFileName).getFile()); try(FileReader fr = new FileReader(file)){ JSONParser parser = new JSONParser(); config = (JSONObject) parser.parse(fr); } catch (ParseException ...
Read now
Unlock full access