我的代码:
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
字符串在渲染时显示占位符:
我想在我的 .properties 文件中重用字符串,但这段代码不起作用。有没有办法解决它,还是我犯了一个错误?
当我取:
public static String SOURCES = prop.getProperty("SOURCES");
我期待“来源”作为输出。
德玛西亚99
人到中年有点甜
相关分类