Wednesday, March 16, 2016

class.getResources()



getClass().getResource()
searches relative to the .class file while
getClass().getClassLoader().getResource()
searches relative to the classpath root.

To obtain current path you can run
public game(){
    String currentPath = this.getClass().getResource("").getPath();
    System.out.println(currentPath);
}
or respectively
public game(){
    String currentPath = this.getClass().getClassLoader().getResource("").getPath();
    System.out.println(currentPath);
}

No comments:

Post a Comment