How to embed xml file into java package and access it?
java, package, xml
Solution
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.
Problem
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?