I am trying to load data from a config file . The code seems correct but not sure why I am getting a null pointer exception . I ran it in debug mode also but not able to find a solution on how to fix it . Appreciate your help .
public class LoadTestData {
static String s = "src/configuration.properties";
public ArrayList<String> getValue(String str)
{
String res;
Properties p = new Properties();
try {
p.load(new FileInputStream(s));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
res = p.getProperty("str");
String[] AL = res.split(",");
ArrayList<String> AL1 = new ArrayList<String>(Arrays.asList(AL));
return AL1;
}
public static void main(String args[])
{
LoadTestData L = new LoadTestData();
ArrayList<String> city = L.getValue("Address");
System.out.println(city.size());
}
}
Here is the test file configuration.properties file
url:https://www.credify.tech/phone/nonDMFunnel
FirstName=vinaya,James,Alex,Alan,Grace,Shilpa,Anand,Saurabh
LastName=Anand,JOnes,West,Delapena,Keesara,Krish,Kiran
Address=37831 Lavender Cmn,33450 Fremont Blvd,1887 Bishop Ave
City=Fremont,Dublin,WalnutCreek
Country =USA
I want to load all the input data values into a ArrayList like ArrayList of City ,State etc