Java:Pfade

Aus Alexander's Wiki
Die druckbare Version wird nicht mehr unterstützt und kann Darstellungsfehler aufweisen. Bitte aktualisiere deine Browser-Lesezeichen und verwende stattdessen die Standard-Druckfunktion des Browsers.
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();
}