通过properties配置文件获取环境变量

在shell脚本中导入环境变量,如export UNSENT_MESSAGES=/log/unsent_messages.txt

在config.properties中,unsentFile=UNSENT_MESSAGES

在java文件中获取变量

property.load(new FileInputStream("config.properties"));
String unsentMessageFile = property.getProperty("unsentFile");
String filePath = System.getenv(unsentMessageFile);

posted @ 2013-09-25 11:15  562323273  阅读(4880)  评论(0编辑  收藏  举报