java读取项⽬外⾯配置⽂件的⽅法
public static void loadProps(String propertiesUrl) { props = new Properties(); InputStream in = null; try {
in =new BufferedInputStream(new FileInputStream(propertiesUrl)); props.load(in);
} catch (FileNotFoundException e) {
logger.error(\"jdbc.properties⽂件未找到\"); } catch (IOException e) {
logger.error(\"出现IOException\"); } finally { try {
if (null != in) { in.close(); }
} catch (IOException e) {
logger.error(\"jdbc.properties⽂件流关闭出现异常\"); } }
logger.debug(\"加载properties⽂件内容完成...........\"); logger.debug(\"properties⽂件内容:\" + props);}
public static String getProperty(String key) {if (null == props) {
logger.debug(\"加载配置⽂件出错\");}
return props.getProperty(key);}