Monday, February 27, 2012

Working with resources (.properties files)

An example:

import java.util.ResourceBundle;

public class Properties {
private static ResourceBundle properties = ResourceBundle.getBundle("SMSComServer");
public static ResourceBundle getPropertyFileRef(){ return properties;}

public final static int WEB_SERVER_PORT = Integer.parseInt(properties.getString("server.web.port"));
}


Attention: Statically loading resources is not the best practice, because for reloading resources the whole application has to be restarted.