开发者

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 :

  1. Read Documentation of Java API
  2. For questions like this write minmal test programs
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜