new File(".").getCanonicalPath();
String directory = System.getProperty("user.dir")
/*************************************************************************************
* Sollte den richtigen Pfad, egal von welcher Position das Programm gestartet worden ist holen
* @return String
************************************************************************************/
protected static String getPath()
{
String path1 = System.getProperty("user.dir");
String path2 = System.getProperty("java.class.path");
try{
if(path2 != null && path2.trim().length() > 0 && path2.indexOf(";") == -1 && path2.indexOf(File.separator) != -1)
{
path2 = path2.substring(0, path2.lastIndexOf(File.separator));
if(!path1.endsWith(File.separator))
path1 = path1.concat(File.separator);
File f1 = new File(path1);
File f2 = new File(path2);
//wenn sie gleich sind
if (f1.getCanonicalPath().equals(f2.getCanonicalPath()))
{
if(!path1.endsWith(File.separator))
path1 = path1.concat(File.separator);
System.out.println("NUTZE PFAD:: " + path1);
return path1;
}
else{
if(!path1.endsWith(File.separator))
path1 = path1.concat(File.separator);
path1 = path1.concat(path2);
System.out.println("NUTZE PFAD:: " + path1);
return path1;
}
}
else {
if(!path1.endsWith(File.separator))
path1 = path1.concat(File.separator);
System.out.println("NUTZE PFAD:: " + path1);
return path1;
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
return null;
}