How do i open a DTD file as a resource in a custom Java action

2
Hi, I have a DTD document that i want to bundle with my custom java class. In the java class i want to read the document, eg getResourceAsStream(). I've put the document in my java source folder, but at deployment time i can't load it. Any suggestions? Thanks!
asked
2 answers
5

Resources within projects are to be placed inside the resources directory of the project. To obtain a reference to the specific file one can use Core.getConfiguration().getResourcesPath().

E.g.: I've placed mysettings.properites inside /resources. Then I can obtain a File using:

File myFile = new File(Core.getConfiguration().getResourcesPath() + File.separator + "mysettings.properties");

From there you can also create a FileInputStream and read its contents.

answered
0

Thanks Arjen. I solved it with a jar added to the userlib. In my case these were external DTDs and not property files, so it made sense to do that way. I will remember this approach when I want to load a file.

answered