My code:
public static InputStream input = null;
public static Properties prop = new Properties();
static public void getConstants(){
Constants constants = new ConstantsEng();
try {
input = CLASS_NAME.class.getClassLoader().getResourceAsStream("FILE_NAME.properties");
prop.load(input);
} catch (IOException e) {
e.printStackTrace();
}
public static String SOURCE = prop.getProperty("SOURCE");
public static String SOURCES = prop.getProperty("SOURCES");
public static String DESTINATION = prop.getProperty("DESTINATION");
public static String DESTINATIONS = prop.getProperty("DESTINATIONS");
FILE_NAME.properties
SOURCE=Source
SOURCES=${SOURCE}s
DESTINATION=Destination
DESTINATIONS=${DESTINATION}s
The strings display with the placeholders in when rendered:
I want to reuse strings in my .properties file but this code doesn't work. Is there any way round it, or am I making a mistake?
When I fetch:
public static String SOURCES = prop.getProperty("SOURCES");
I'm expecting "Sources" as output.