I am having trouble finding a way to have Java link the path of the directory where the project files are located.
I am aware of this and other versions that does the same thing
System.getProperty("user.dir"))
But this only links to the working directory and I really need it to link to where the files are. This way program will always read the file I need it to read without there ever being any issues with not the correct path.
I know how to do this in Python but I cannot find a way to do it in Java
In python it is easy, is this lacking in Java is that why I cannot find anything that does it?
os.path.dirname(__file__)
Do I need to implement one line of code in python to make this work? Seems kinda odd there must be a way to make this work like in Python.
public class Test {
public static void main(String argvs[]) {
String file = "/directoryname/filename";
System.out.println(System.getProperty("user.dir")+ file); //I want this to link to the directory the Class is located so it can open up a directory there.
}
}