Java properties 文件读取
package com.souche.vs.util;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
public class ConfKit {
private static Properties props = new Properties();
static
{
try
{
props.load(ConfKit.class.getResourceAsStream("/parm.properties"));
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static String get(String key)
{
String result = props.getProperty(key);
if (StringUtils.isBlank(result)) {
result = "";
}
return result;
}
public static void setProps(Properties p)
{
props = p;
}
}