Hi,
I have got a piece of code(method) below that reads a properties file. For some reason, I am getting an error when compiling, at the point where I try to catch the IOException (exception needs to be caught because the Properties.load class throws it). Does anyone know why I am getting this please?
//reading properties file test
public void readXML(){
Properties config = new Properties();
String PROPS_FILE = "/location/file.properties";
try {
Class clazz = LdapConnect.class;
config.load(clazz.getResourceAsStream(PROPS_FILE));
}
catch (IOException e) {
System.err.println("Caught IOException: " +e.getMessage());
}
catch (NullPointerException npe) {
System.err.println("Caught NullPointerException: " +npe.getMessage());
}
String value = config.getProperty("field1");
String value1 = config.getProperty("field2");
System.out.println("THE VALUE IS :"+value);
System.out.println("THE VALUE1 IS :"+value1);
}
I have got a piece of code(method) below that reads a properties file. For some reason, I am getting an error when compiling, at the point where I try to catch the IOException (exception needs to be caught because the Properties.load class throws it). Does anyone know why I am getting this please?
//reading properties file test
public void readXML(){
Properties config = new Properties();
String PROPS_FILE = "/location/file.properties";
try {
Class clazz = LdapConnect.class;
config.load(clazz.getResourceAsStream(PROPS_FILE));
}
catch (IOException e) {
System.err.println("Caught IOException: " +e.getMessage());
}
catch (NullPointerException npe) {
System.err.println("Caught NullPointerException: " +npe.getMessage());
}
String value = config.getProperty("field1");
String value1 = config.getProperty("field2");
System.out.println("THE VALUE IS :"+value);
System.out.println("THE VALUE1 IS :"+value1);
}