你必须severals事情尝试:
Java属性
private Properties _properties;
private void init(){
_properties = new Properties();
InputStream configurationFileIS = PropertiesConfigurationHandler.class.getClassLoader().getResourceAsStream(CONFIGURATION_FILE);
_properties.load(configurationFileIS);
}
public String getStringValue(String path) {
return _properties.getProperty(path);
}
和属性文件将类似于
an.element.to.be.configured.like.a.path=/dev/null
但你也可以使用Spring上下文
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
WEB-INF/classes/config/properties/database.properties
classpath:config/properties/database.properties
和内部database.properties的元素将被访问的方式
“${jdbc.username}”
–
为了您的具体问题。
您可以创建一个文件constants.properties
executable.run=C:\\server\\rd.exe
incoming.file=C:\\file.lic
executable.params=-z
log.file=C:\\File\\log.txt
,然后你调用向GetStringValue初始化后:
String executable = getStringValue(“executable.run”);
String filein = getStringValue(“incoming.file”);
String params = getStringValue(“executable.params”);
String log = getStringValue(“log.file”);
然后,你可以做和的rt.exec而不是使用硬编码字符串,你可以使用之前检索到的。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177365.html原文链接:https://javaforall.net
