Wie gebe ich den Pfad an zu einem File im selben ordner?

1 Antwort

In http://docs.oracle.com/javase/8/docs/api/java/io/File.html findest du Folgendes:

A pathname, whether abstract or in string form, may be either
absolute or relative. An absolute pathname is complete in
that no other information is required in order to locate the file that it
denotes. A relative pathname, in contrast, must be interpreted in terms of
information taken from some other pathname. By default the classes in the
java.io package always resolve relative pathnames against the
current user directory. This directory is named by the system property
user.dir, and is typically the directory in which the Java
virtual machine was invoked.

Das heißt, du musst einfach nur den Dateinamen angeben, ohne irgendeinen Pfad, und bist meistens damit im Verzeichnis, wo die JAR-Datei aufgerufen wurde.