Properties文件工具读取类
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class CommonPropertiesUtil {
private static CommonPropertiesUtil instance;
private CommonPropertiesUtil(){
}
public static synchronized CommonPropertiesUtil getInstance(){
if(instance == null){
instance = new CommonPropertiesUtil();
}
return instance;
}
/**
* 读取配置文件
* @return
*/
public Properties loadUploadProperty() {
Properties prop=new Properties();
InputStream is = null;
try {
is = this.getClass().getResourceAsStream("/uploadConfig.properties");
prop.load(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
return prop;
}
}