Save it in a file .properties.
config.properties
tile.size=16
screenshot.dir=..\\somepath\\..
Reading
Properties properties = new Properties();
properties.load(...)
Using
int tileSize = Integer.valueOf(properties.getProperty("tile.size"));
String screenshotDir = properties.getProperty("screenshot.dir");
To simplify and save minimal changes, you can also do something like this:
public class Globals {
private static final Properties properties = new Properties();
static {
}
public static final int TILE_SIZE =
Integer.valueOf(properties.getProperty("tile.size"));
public static final String SCREENSHOT_DIR =
properties.getProperty("screenshot.dir");
}
source
share