How to test value in a property file?
Happy Halloween!
I would like to know how to test a value of a property file.... it seems that making a variable equal to properties.getProperty("key") and then testing that sting value (assume the value is halloween) wont work...
example:
Code :
//imported necessary imports
public void aMethod(){
Properties props = new Properties();
try{
props.load(new FileInputStream(new File("filename.properties"));
value = props.getProperty("lastHoliday");
if(value == "halloween"){
System.out.println("BOO!");
}
}catch(Exception e){
}
}
in the properties file:
Do you need to test the value a different way?
Re: How to test value in a property file?
You rarely want to test Strings (or other objects) with ==, use the equals method instead.