Java:Pfade

Aus Alexander's Wiki
Zur Navigation springen Zur Suche springen
private static String getPropertyLocation() {
  String propertiesFilePath = "/EFUS/efus.properties";
  File propertiesFile = new File(propertiesFilePath);

  if (!propertiesFile.exists()) {
    try {
      CodeSource codeSource = EfusConfiguration.class.getProtectionDomain().getCodeSource();
      File jarFile = new File(codeSource.getLocation().toURI().getPath());
      String jarDir = jarFile.getParentFile().getPath();
      propertiesFile = new File(jarDir + System.getProperty("file.separator") + propertiesFilePath);
    } catch (Exception ex) {}
  }

  // System.out.println(propertiesFile.getAbsolutePath());
  return propertiesFile.getAbsolutePath();
}