Java eclipse referencing files in project using relative paths
I am trying to upload something to the web using one of Apache's client libraries. However I am having trouble locating the resource file to upload. My project setup looks like this:
Root/src/a/b/c/d/program.java
Root/resource/resourceFile.txt
I was wondering what the string path 开发者_JS百科would be for referencing that resource file from program.java?
File f = new File("what path would go here?");
Thanks in advance.
- Eclipse will (by default) not include this file in the built project.
- The Project Path Information from Eclipse environment is not available in the built project
If you run this in Eclipse, it will display the base path of your application.
Find out with
File f = new File(".");
System.out.println(f.getAbsolutePath());
Tips :
- Read Documentation of Java API
- For questions like this write minmal test programs
精彩评论