public final class FilePathGetUtil {
private static final Charset CHARSET = StandardCharsets.UTF_8;
private static final String propertiesPathWindows = "/conf/filePath.properties";
private static final String propertiesPathLinux = "/conf/filePath.properties";
private Properties prop = null;
public String getFilePath(String key){
String fileName = "";
File file = null;
try {
String osName = System.getProperty("os.name");
if (osName == null)
{
osName = "linux";
}
osName = osName.toLowerCase(Locale.ENGLISH);
if (osName.indexOf("windows") != -1)
{
file = new File(propertiesPathWindows);
} else
{
file = new File(propertiesPathLinux);
}
BufferedReader br = Files.newBufferedReader(file.toPath(), CHARSET);
this.prop = new Properties();
this.prop.load(br);
fileName = this.prop.getProperty(key);
} catch (FileNotFoundException e)
{
} catch (IOException e)
{
}
return fileName;
}
}