ReadProperties

package com.hgx.test.common;

import java.io.*;
import java.util.Properties;

/**
* config file read
*
* @author sasou <admin@php-gene.com> web:http://www.php-gene.com/
* @version 1.0.0
*/
public class ReadProperties {
static final String propertiesFilename = "SysConfig.properties";
Properties p = new Properties();

public Properties readProperties() {
/* try {
InputStream inputStream = new BufferedInputStream(
new FileInputStream(System.getProperty("user.dir") + "/src/main/resources/" + propertiesFilename));
try {
p.load(inputStream);
} catch (IOException e) {

}
} catch (FileNotFoundException e) {

}*/

try {
InputStream inputStream = ClassLoader.getSystemResourceAsStream(propertiesFilename);
try {
p.load(inputStream);
} catch (IOException e) {

}
} catch (Exception e) {

}
return p;
}
}
原文地址:https://www.cnblogs.com/heguoxiu/p/10135337.html