tags:

views:

133

answers:

1

I have a XML file with data that is used in both my C# and Java version of a library. Ideally I want to embed this XML file in a package in that library.

I only need to access it from within my library, so I was wondering: is that possible?

+6  A: 

In Java, you could include the XML file itself in the JAR file. You can then use something like this:

InputStream istream = getClass().getResourceAsStream("/resource/path/to/some.xml");

And parse your InputStream as normal.

The above getResourceAsStream() looks in the current classpath, which would include the contents of any JAR files.

Adam Batkin
This worked perfectly both in jarred export and just project reference!
Peterdk