| [news.eclipse.newcomer] Re: Problem with finding a text file in Eclipse workspace |
Stefan Zugal wrote:Anyway, if you want to take advantage of the Eclipse workspace, you will need the org.eclipse.core.resources plugin:
ResourcesPlugin.getWorkspace()
will return the workspace. Eclipse help should give you more information about how to use the workspace.
If you want to access files of your plugin, you may use: Bundle#getResource(String name)
HTH, Stefan
This is the procedure to follow if you are writing an Eclipse plugin. To me, it sounds more like you are writing a Java application. In this case, you should look into the Class.getResource() and Class.getResourceAsStream() methods. These will search for the resource on your classpath. My guess is that something along the lines of: this.getClass().getResourceAsStream("/temp.txt") should work. Read the Javadoc for both methods and pay attention to the discussion about leading '/' characters for pathing purposes.
Hope this helps, Eric