package com.oscerd.github.mongodb.config;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class MongoPropertyReader {
private String propFileName;
public String getPropFileName() {
return propFileName;
}
public void setPropFileName(String propFileName) {
this.propFileName = propFileName;
}
public MongoPropertyReader(String propFileName) {
super();
this.propFileName = propFileName;
}
public Properties getProperties() throws IOException {
Properties prop = new Properties();
InputStream inputStream = null;
try {
inputStream = getClass().getClassLoader().getResourceAsStream(
propFileName);
prop.load(inputStream);
if (inputStream == null) {
throw new FileNotFoundException("property file '"
+ propFileName + "' not found in the classpath");
}
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return prop;
}
}