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?
From stackoverflow
-
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.Peterdk : This worked perfectly both in jarred export and just project reference!
0 comments:
Post a Comment