import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
public class ConvoyKBConstants {
/**
*
* @param proName
* @return
*/
public static String loadConfigFile(String proName) {
return baseLoad("convoykb.properties", proName);
}
/**
*
* @param fileName
* @param proName
* @return
*/
public static String loadFile(String fileName,String proName){
return baseLoad(fileName, proName);
}
/**
*
* @param fileName
* @param proName
* @return
*/
private static String baseLoad(String fileName, String proName) {
Properties properties;
String name = getReasourcePath(fileName);
properties = new Properties();
FileInputStream fis=null;
try {
fis=new FileInputStream(name);
properties.load(fis);
} catch (FileNotFoundException e) {
e.printStackTrace();
// log.error("",e);
} catch (IOException e) {
e.printStackTrace();
// log.error("",e);
}finally{
try {
if(fis!=null)
fis.close();
} catch (IOException e) {
e.printStackTrace();
// log.error("",e);
}
}
return properties.getProperty(proName);
}
/**
*
* @param resourceName
* @return
*/
public static String getReasourcePath(String resourceName) {
// log.info("loading "+resourceName);
if(ConvoyKBConstants.class.getClassLoader().getResource(resourceName)==null) {
// log.error("Cound not find resource: "+resourceName);
return resourceName;
}
return ConvoyKBConstants.class.getClassLoader().getResource(resourceName).getPath();
}